Assume that your main server (the one you use the most) is ServerA.
And from ServerA, you want to automatically login to ServerB.
For illustration purpose, ServerB can be a repo server and you don’t want to keep being asked for password everytime you want to commit files.
1. At ServerA issue: # ssh-keygen -t rsa
This will create a public + ptivate key for ServerA
2. Enter (empty) for paraphrase
Your identification has been saved in /home/ronald/.ssh/id_rsa.
Your public key has been saved in /home/ronald/.ssh/id_rsa.pub.
3. Copy over the newly created public key from ServerA to ServerB
scp .ssh/id_rsa.pub ronald@ServerB:~/id_rsa.pub.ServerA
Note that once the file arrives at ServerB, it named as id_rsa.pub.ServerA (not id_rsa.pub), and it will be stored at ronald’s home directory at ServerB.
4. Ssh to ServerB, and issue this command:
cat id_rsa.pub.ServerA >> .ssh/authorized_keys
ServerA public key will be merged/appended to ServerB authorized_keys file.
This way everytime you want to access ServerB from ServerA, you won’t be asked for a password.