How to Generate an SSH Key and Add It To Your Web Hosting¶
You can add one or many SSH public keys to your web hosting and use them to log in to the sFTP and git services instead of using your web hosting’s password.
SSH key authentication is not available on the Emergency Console. You always need to use your web hosting’s password to connect to the console.
Follow the instructions below to learn how to generate an SSH key pair and how to add the contents of your public key file to your web hosting.
You can use the
ssh-keygen command to generate an SSH key pair, as per the example below. Two files will be created with this command and, by default, will be named
id_rsa.pub and placed in a ~/.ssh/ directory.
Both files are simple text files containing your private (
id_rsa) and public (
id_rsa.pub) keys. You’ll be able to upload the content of the public key file to your web hosting to be able to authenticate via SSH.
$ ssh-keygen -t rsa -b 2048 Generating public/private rsa key pair. Enter file in which to save the key (/home/user/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/user/.ssh/id_rsa Your public key has been saved in /home/user/.ssh/id_rsa.pub The key fingerprint is: eb:79:fb:3f:15:ff:3a:04:dd:46:74:3b:da:a2:2b:9b user@hostname The key's randomart image is: +--[ RSA 2048]----+ | .o| | +| | . = | | . +.+| | S + oo| | . . o o| | . . . ..| | . oo . o .| | oE++..o+ | +-----------------+
Once the files are created, you can open the public key file with a text editor and copy its contents to your clipboard.
Follow the instructions in the next section to learn where to paste the contents of your file and enable SSH key authentication on your web hosting.
On Windows, you can use PuTTY as your SSH client. PuTTY comes with a tool called
PuTTYGen that will enable you to generate SSH keys.
Use the information below to generate your SSH key pair:
You can follow PuTTY’s documentation about SSH keys to learn how to generate your key pair.
Once you have generated an SSH key pair, you can upload the contents of your public key file from your web hosting’s management page.
In the “Security” section, click the “Add an SSH key” button.
Then, select the “Create a new key” tab and paste the contents of your public key file in the “Public Key” field. If you wish to save this key in your keyring to quickly add it to other web hostings, check the “Add to my keyring” checkbox and enter a “Key name”.
Once you have completed the steps described above, click the “Add SSH key” button to save your key. It’ll now be added to your web hosting and, if you chose to, saved to your keyring.
After a few moments, you’ll be able to login to your web hosting using your SSH key instead of your password. Remember that this authentication method only works for the sFTP and git+SSH services, and not for console access.
You can manage public SSH keys that were added to your web hostings by connecting to your web hosting via sFTP directly and not from the web hosting management page.
Any keys that were added to a web hosting will be placed in a file located at the root of your sFTP directory listing at the following path:
You can add new keys directly to this file and you can also remove keys by deleting the relevant lines from this file.
Login to your web hosting via SFTP
Navigate to the folder named
.sshlocated at the root of your sFTP directory listing
To remove all SSH public keys simply delete the
authorized_keysfile. Alternatively, you can edit the file and remove only the public SSH keys that you wish by deleting the line that contains them.