18 - How to Setup password-less connection via ssh in Linux
In this article we will show you how to setup password-less log in using ssh keys to connect to remote Linux servers without entering password. Using Password-less log in with SSH keys will increase the trust between two Linux servers for easy file synchronization or transfer.
SSH Password-less log in is one of the best way to automate tasks such as automatic backups with scripts, synchronization files using scp and remote command execution.
Let's follow the steps in creating the password-less connection.
1- First you need to install SSH-client .
2- Generate a pair of public keys.
To do so you need to use the commands:(just press enter until the process finishes)
3- Set directory permission
Next make sure you have correct permission on .ssh directory:
4- Create the file authorized_keys inside .ssh folder and copy the content of the id_pub.pub inside of it.
This will hold the used keys for password-less connection.
5- Change the permission on authorized_keys.
6- Do the same on the other server where you want to connect password-less.
Just follow the first 5 steps.
7- Copy public key from one server to another and place it inside the authorized_keys file.
Then try to connect to the server. You will be asked if you want to continue and the host will be added to to the known_hosts file.