SSH Without Entering Password

To set up an automatic login from host1 to host2 as user bob follow the steps below, substituting hostnames and user whereever necessary

METHOD 1


- Log into host1 as bob and type in a terminal ssh-keygen -t rsa


you will see the following or similiar output


Generating public/private rsa key pair.
Enter file in which to save the key (/home/bob/.ssh/id_rsa):
Created directory '/home/bob/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/bob/.ssh/id_rsa.
Your public key has been saved in /home/bob/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A


- Log into host2 and make the needed folders by typing in a terminal
ssh bob@host2 mkdir -p .ssh


- Now we need to take the key from host1 and attatch it to the host2 keyfile by typing in a terminal cat .ssh/id_rsa.pub | ssh bob@host2 'cat >> .ssh/authorized_keys'


- You can now login as bob into host2 from host1 without a password :-D


METHOD 2


From HOST1 type the following:


ssh-keygen


ssh-copy-id -i ~/.ssh/id_rsa.pub HOST2