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
- 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:
- 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
From HOST1 type the following:
ssh-copy-id -i ~/.ssh/id_rsa.pub HOST2