Configuring SSH public key access in cPanel allows for a more secure way of logging into a web server than using a password.
Using password authentication can eventually lead to the password to be cracked with a brute force attack. SSH keys are nearly impossible to decipher by brute force alone, because the public key resides on the server (the remote location), and the private key resides locally on your computer/server.
When you attempt to login to a server, both the public and private key are compared. If they ‘match’, then you will be allowed to login to the server location.
To use SSH public key authentication to login to the web server, within cPanel, head to the relevant account to provide SSH access for within WebHost Manager (WHM) under
Then click on
SSH Access under the
Within this area, click on
Manage SSH Keys and then
You will then be presented with a screen with fields allowing you to paste in a private and public key.
As the note suggests at the bottom of the form, usually adding one of the keys will be enough. If you’re attempting to access the server from your local machine, you should add in your public key into the form.
To access your public key, you can open terminal and use the following commands.
$ cat ~/.ssh/id_rsa.pub
$ cat ~/.ssh/id_dsa.pub
If you don’t have these files created, you will need to generate a key pair using the
Paste the contents of the public key into the form and save the key.
By default, the keys added into cPanel are not authorised, therefore click on
Manage and authorise the key.
You should then be able to SSH into your server without being prompted for a password using
If you don’t have access to cPanel (or don’t have it installed), you can use the
ssh-copy-id command to copy the public key over to the remote host.
ssh-copy-id can be used installing homebrew.
brew install ssh-copy-id
And then used as per the below.