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

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

SSHKEY1

1. Click on Manage SSH keys

SSHKEY2

On the next page you can either import 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 new SSH key pair click on Generate a new Key option

SSHKEY3

On generator page specify password (passphrase), Key Name, Key Type and Size. Maximum DSA key size allowed by cPanel is 1024.

NOTE: Greater key sizes are more secure, but they may increase authentication time.

NOTE 2: id_dsa/id_rsa key names are used by default in most cases, so if you want to use different names make sure they are also used during the establishment of SSH connection.

SSHKEY4

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 Manage authorization option

SSHKEY5

On the next page click on Authorize button

SSHKEY6

2.3. Acquiring key pair

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

SSHKEY7

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

SSHKEY8

3. Import of the existing keys

If you already have a key pair generated by other means you can import them using Import Key option

SSHKEY10

In public/private key fields input your keys, select name for the key pair, passphrase and click Import

SSHKEY9

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 Putty SSH client and key pair generated by cPanel in order to access server via SSH:

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

4.2. In PuTTy folder run puttygen.exe, in top menu select 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)

SSHKEY12

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

SSHKEY13

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

SSHKEY14

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

SSHKEY15

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

SSHKEY16

In console window you will be asked for login and passphrase

SSHKEY17

This is it!

Need any help? Contact our HelpDesk

About Author

Leave a Reply

Your email address will not be published. Required fields are marked *