Introduction to SSH Public Key
In this tutorial we are going to add our public key for authentication through SSH. There are many benefits to this type of setup which include:
Once you have your public key that you generated via PuTTY and/or Linux Commandline, you will need to add it to the destination server that you are trying to connect to.
If you have not generated your public and private key yet you can follow either of the below howtos:
How to Set Up SSH Keys with PuTTY
To do this we will first create the hidden .ssh directory:
Now we will create/edit the authorized_keys that will be located inside the .ssh directory we just created.
You should now paste your public key into this file. Please note make sure they key is contained on one line.
Example should look like this:
# cat .ssh/authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAt+PzzOFcecabwsXnjPPd+eqrqF5d2qh6kRIbnInSgwqWlPvnyfxa2Ye1xhGjCssbYdPWA7epJ/42yMFQfg6RGynW9XjWMomWeA/1+2LGY4B7JBJQfuTdDB/AimJRQvlSmxklfktmuqx0S8u67mLdkRWY+uQD8Ec7TCxWC9pU5Hv3Hq4Rfg5KLZl/gcJyMCr3nhKXXnL65pAM0EdCmkefHxvHJ4InVuzXmDru7GVQXH1bd3Uy9UIRhIs9wORlTvwesUzWEH/eTCjGSTgGRaEguo9FISRcilODuYQrcrvN8eILZxXNsiprw0azMibonkb3yuQ6mfVxtRoB4JL3vsFIbw== solarvps_key
Let’s now set permissions on the key files:
chmod 700 ~/.ssh chmod 600 ~/.ssh/id_rsa
The above permissions are required if StrictModes is set to yes in /etc/ssh/sshd_config (the default).
You should now be able to SSH to your server using your SSH Key authentication.
Tags: centos, keys, Public Key, Security, ssh