Add SSH Public and Private Keys

Manually add SSH public and private SSH keys.

“This step is different for each hosting provider.”

Since we use GitHub, we need to do this manually.

Most hosting providers, especially those using cPanel to generate SSH keys in RSA or DSA format, are outdated by GitHub standards.

With cPanel, you can import private and public SSH keys from the Control Panel, but SiteGround doesn’t allow us to do that for security reasons.

1. Log in to your server with PuTTY

Note: If you have completed Configure PuTTY with Pageant, you can open PuTTY, select the Saved Session and click on the Open button.

Now, run the following sequence with commands:

$ nano ~/.ssh/id_ecdsa
> Content from C:\Users\username\.ssh\id_ecdsa
$ nano ~/.ssh/
> Content from C:\Users\username\.ssh\
$ chmod 600 ~/.ssh/id_ecdsa*
$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/id_ecdsa

Note: You should copy/paste the contents from your locally created OpenSSH keys files onto the server.

In addition, if your server doesn’t support ECDSA, you need to add the RSA public and private keys.

2. Test your SSH connection

To test your SSH connection, you can run the following command:

$ ssh -T
> The authenticity of host ' (IP ADDRESS)' can't be established.
> RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
> Are you sure you want to continue connecting (yes/no)? yes
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access.
3. Automate your Git authentication

To use Git, you need to type the last two commands every time you log in to authenticate.

To make it easier and automate the process a bit, you can add into ~/.bash_profile the following:

if [ -z "$SSH_AUTH_SOCK" ] ; then
  { eval `ssh-agent -s`; ssh-add ~/.ssh/id_ecdsa; } &>/dev/null

Now on every login, you will be prompted for your SSH key passphrase and continue with your Git commands without the need to type any commands.

Or, if you want to go further and have permissions install and set up Keychain by Funtoo.