To manage our SSH keys in cPanel, we must access the
SSH Access menu, inside our cPanel, once inside, click on
"Manage SSH Keys" where we will have a list of the public and private keys created, as well as several options to add, authorize or delete the keys.
Generate an SSH key in cPanel
To create a new SSH key from cPanel, click on
"Generate a New Key":
Once inside, a form will appear that we will have to fill in:
Key Name: We can leave it by default to id_rsa, so it will be the key that our account will look for by default every time we try to connect via SSH.
Key Password: The password of the SSH key, it is mandatory if we are generating the SSH key through cPanel. We will have to remember it every time that SSH connections are made with this key.
Key Type: RSA
Key Size: 4096
After filling it, we click on
Generate Key, itwill
show us a confirmation screen indicating the paths of the keys, as well as the fingerprint.
Authorize or Download SSH key
Authorize public key
In the list of SSH keys we will see two new keys with the name we entered earlier, a public key and a private key.
We may only need one of the two keys, usually the public key, so we must authorize it by clicking on "Manage", highlighted with a blue box below:
. Inside, simply click on "Authorize" to allow connections using that public key.
Download SSH key
To obtain the content of the public key, click on
"View/Download", highlighted with an orange box in the image above.
It will allow us to copy the key or download it:
For a private key, the process will be exactly the same.
Generate an SSH key from the console
To generate an SSH key from the console we will need access to it.
Once you have connected via SSH to the server, you can generate an SSH key pair using the following commands:
ssh-keygen -t rsa -b 4096 -C "soporte@factoriadigital.com"
Under the -C parameter, we can put something identifying, usually email, to help us identify the purpose or identity of that key.
It will ask for the name of the key, if we leave it empty, it will take the default one: id_rsa, which is already correct.
It will also ask for a password to be able to use the SSH key. If we want to leave it without password, it is also possible, simply pressing Enter and leaving it empty.
Once we finish, the following will appear:
Where it will indicate us the path where the public and private key has been generated, as well as the fingerprint.
To visualize the recently created key we will be able to do it from cPanel, as it is observed in the previous point:
"Authorize or Download SSH key" or, by means of the command:
cat /home/pruebasfd/.ssh/id_rsa.pub
With the path of the key shown above.
Import an existing SSH key in cPanel
To import an existing SSH key, access the
"Import Key" option:
Inside, we will be able to enter our public and/or private key. It is not necessary to enter both if we are not going to use them. It is totally acceptable to enter only the public key, for example.
Therefore, to import a public key into the default key (id_rsa), we will copy the content of the public key into the field
"Paste the public key into the following text box":
Done this and after clicking
"Import", we will already have our existing SSH key imported.
Si todavía tienes dudas, contacta con nosotros y te ayudamos.