This has proven more secure over standard username/password authentication.
You can generate an SSH key pair directly in cPanel, or you can generate the keys yourself and just upload the public one in cPanel to use with your hosting account.
When generating SSH keys yourself under Linux, you can use the ssh-keygen command. To do so follow these steps:
Enter file in which to save the key (/home/youruser/.ssh/id_rsa):
The public key will be saved in the same location, under the same file name, but with the .pub extension. Type in nothing to use the default location, which is /home/youruser/.ssh/id_rsa.
The entire key pair generation process would look like this:
user@localhost: ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/youruser/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
16:8e:e8:f2:1d:c9:b9:cf:43:9a:b3:3c:c1:1f:95:93 user@localhost
This will create a private key written to /home/youruser/.ssh/id_rsa and a public key written to /home/youruser/.ssh/id_rsa.pub.
The private key needs to be loaded in your Terminal using the ssh-add command:
After which you will be asked to enter the passphrase of your key.
You can generate an SSH key pair directly in cPanel, or you can generate the keys yourself and just upload the public one in cPanel to use with your hosting account.
When generating SSH keys yourself under Linux, you can use the ssh-keygen command. To do so follow these steps:
- Open up the Terminal
- Type in the following command:
ssh-keygen -t rsa
- Next you will have to type in the location of the file where you would like to save the private key.
Enter file in which to save the key (/home/youruser/.ssh/id_rsa):
The public key will be saved in the same location, under the same file name, but with the .pub extension. Type in nothing to use the default location, which is /home/youruser/.ssh/id_rsa.
- Finally you will have to type in a password. This will be the password required to load the private key and use it to connect via SSH later on:
Enter passphrase (empty for no passphrase):
The entire key pair generation process would look like this:
user@localhost: ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/youruser/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
16:8e:e8:f2:1d:c9:b9:cf:43:9a:b3:3c:c1:1f:95:93 user@localhost
This will create a private key written to /home/youruser/.ssh/id_rsa and a public key written to /home/youruser/.ssh/id_rsa.pub.
The private key needs to be loaded in your Terminal using the ssh-add command:
ssh-add /home/youruser/.ssh/id_rsa
After which you will be asked to enter the passphrase of your key.