I always prefer to use PKI authentication to my devices, if I have a chance to configure that.
– We don’t have to type password every time, it decreases the risk to type your passwd to the chat window for example.
– It’s much more stronger than the your dog’s name or your date of birth 🙂
– Not necessary to change it periodically
So if we have a possibility, I recommend to use PKI authentication.
First we have to generate a private/public keypair locally:
On windows(with putty):
Download the putty keygen from here, and run it:
On Linux machines:
ssh-keygen -t rsa
It will create 2 files in the ~/.ssh/ dir.
id_rsa : identification (private) key
id_rsa.pub : public key
We get the keypair in both cases, we have to copy that to the remote machine.
Create the necessary directory, if it doesn’t exist:
mkdir .ssh cd .ssh
And create the file for the public keys:
In this file, we will store our public keys (!!!1 key in 1 line)
If you copy the public key correctly, then you will able to log in without password.