How to connect via SSH using keys

Your SSH session can be authenticated either with the username and password or with a pair of private/public keys. It is recommended to use the latter, as it is considered to be a more secure and convenient solution: 

for cPanel paper_lantern theme:

In cPanel you can manage SSH keys in the SSH/Shell access menu: 



1. Click on Manage SSH keys



On the next page, you can either import the existing pair of keys or generate a new one. 

2. Create a new pair of SSH keys

2.1. Public and private keys generation 

In order to generate a new SSH key pair click on the Generate a new Key option: 




On the generator page, specify the password (passphrase), Key Name, Key Type and Size.
The maximum allowed DSA key size is 1024 which is not enough to guarantee its security nowadays. That's why we suggest using only RSA with 2048 bits: 



Once everything is set, click Generate Key

Now you should see both private and public keys you created. 

2.2. Public key authorization 

In order to authorize SSH access to your hosting account by the private key you created, click on the Manage authorization option: 



On the next page, click on the Authorize button: 

 

2.3. Acquiring a key pair

You can view and download keys you have in cPanel by clicking on the View/Download button: 



Click on Download Key (it will be saved in a simple text document on your side) or just copy/paste the provided key if needed: 




3. Import of the existing keys

If you already have a key pair generated by other means, you can import the public key using the Import Key option: 



Next, fill in the required details:

  • Choose a name for this key (defaults to id_dsa): type in id_rsa;
  • Paste the Private Key in this box: leave it empty (this field is only used in cases, where you want to have SSH access from your cPanel account to other servers via the keys);
  • Passphrase: input the passphrase;
  • Paste the public key into the following text box: on your local computer open your public key file (e.g./User/name/.ssh/id_rsa.pub) > copy and paste the content of that file into the field;
  • Click Import



Once done, do not forget to authorize your imported public key in the same way as in step 2.2. 

4. Using Putty and SSH key pair to connect 

In this example, we will use the Putty SSH client and key pair generated by cPanel in order to access the server via SSH: 

4.1. Download the Private key as it is shown in step 2.3. 

4.2. In the PuTTy folder, run puttygen.exe; in the top menu select the File tab and click on Load private key and select your private key file (make sure All files (*.*) filter is used so you can see your downloaded private key file): 



You will be asked for the passphrase you specified during the key generation in step 2.1. After entering it you should receive a successful import message: 

 

Now click on Save private key and save your key as a .ppk file which will be needed later: 



3. Run the PuTTy client (putty.exe), select Connection > SSH > Auth and in the Authentication parameters section, click on Browse to select the saved .ppk file: 

 

Once done, get back to the Session section and input the server name (IP address) and specify SSH port (it should be 21098 for all shared servers accounts) and click Open

 

In the console window, you will be asked for the login and passphrase: 

 


for cPanel x3 theme:

In cPanel you can manage SSH keys in the SSH/Shell access menu: 



1. Click on Manage SSH keys



On the next page, you can either import the existing pair of keys or generate a new one. 

2. Create a new pair of SSH keys

2.1. Public and private keys generation 

In order to generate a new SSH key pair click on the Generate a new Key option: 




On the generator page, specify the password (passphrase), Key Name, Key Type and Size.
The maximum allowed DSA key size is 1024 which is not enough to guarantee its security nowadays. That's why we suggest using only RSA with 2048 bits: 



Once everything is set, click Generate Key

Now you should see both private and public keys you created. 

2.2. Public key authorization 

In order to authorize SSH access to your hosting account by the private key you created, click on the Manage authorization option: 



On the next page, click on the Authorize button: 

 

2.3. Acquiring a key pair

You can view and download keys you have in cPanel by clicking on the View/Download button: 



Click on Download Key (it will be saved in a simple text document on your side) or just copy/paste the provided key if needed: 




3. Import of the existing keys

If you already have a key pair generated by other means, you can import them using the Import Keyoption: 




Next, fill in the required details:

 

  • Choose a name for this key (defaults to id_dsa): type in id_rsa;
  • Paste the Private Key in this box: leave it empty (this field is only used in cases, where you want to have SSH access from your cPanel account to other servers via the keys);
  • Passphrase: input the passphrase;
  • Paste the public key into the following text box: on your local computer open your public key file (e.g./User/name/.ssh/id_rsa.pub) > copy and paste the content of that file into the field;
  • Click Import



Once done, do not forget to authorize your imported public key in the same way as in step 2.2. 

4. Using Putty and SSH key pair to connect 

In this example, we will use the Putty SSH client and key pair generated by cPanel in order to access the server via SSH: 

4.1. Download the Private key as it is shown in step 2.3. 

4.2. In the PuTTy folder, run puttygen.exe; in the top menu select the File tab and click on Load private key and select your private key file (make sure All files (*.*) filter is used so you can see your downloaded private key file): 



You will be asked for the passphrase you specified during the key generation in step 2.1. After entering it you should receive a successful import message: 

 

Now click on Save private key and save your key as a .ppk file which will be needed later: 



3. Run the PuTTy client (putty.exe), select Connection > SSH > Auth and in the Authentication parameters section, click on Browse to select the saved .ppk file: 

 

Once done, get back to the Session section and input the server name (IP address) and specify SSH port (it should be 21098 for all shared servers accounts) and click Open

 

In the console window, you will be asked for the login and passphrase: 

 


That's it!

Was this answer helpful?

 Print this Article

Also Read

How Clear DNS History/ Cache

To clear your DNS history/cache, please follow the procedure belowClick Start > Control Panel...

Limiting Simultaneous Connections in FileZilla

Open FileZilla. Access the Site Manager.   Click your site, then select the Transfer...

How to increase upload limit

How to increase memory limit, maximum execution time, maximum input time and maimum post...

How to fix or reset file and folder permissions

In the event that your file/directory permissions are changed under your account for any reason...

Commonly Used Port Numbers

This is a list of commonly used ports, and does not include all possible ports that may be opened...


Our official partners