In order to ssh to another machine you first need to generate ssh keys. To do this follow the steps below:
All of our files will be located in your /home/.ssh. By default, there you may only have a known_hosts file, which we will be using later.
Generate SSH Keys
As the user you want to generate keys for, run
ssh-keygen. This creates my public and private rsa keys as seen in the screenshot below.
Passwordless SSH Login
In order to allow passwordless logins from another machine, we have to copy the contents of id_rsa.pub on our host machine, into /home/.ssh/authorized_keys on the destination machine we want to login to. In this example, I want to be able to login from the machine called “First”, into the machine called “Second”.
On the source machine, cat /home/.ssh/id_rsa.pub
On the destination machine, create
authorized_keys in /home/.ssh.
copy the contents of the id_rsa.pub from the source machine into the
authoized_keys file on the destination machine. In the image below, the left window is the source machine, the right window is a vim of .ssh/authorized_keys
640 permissions on authorized_keys using
chmod 640 athorized_keys. A summary of the things required to do on the destination host can be seen in the screenshot below:
Now I can login without entering my password!