SSH without a password
Assume you have to shh to targethost with a user without using password every time from the machine myhost-lap and user myhostFirst generate a public key as follows
myhost@myhost-lap:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/myhost/.ssh/id_rsa): Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/myhost/.ssh/id_rsa.
Your public key has been saved in /home/myhost/.ssh/id_rsa.pub.
The key fingerprint is:
ec:f5:f5:4a:af:9d:e8:82:1a:76:1d:f9:04:4d:4f:cb myhost@myhost-lap
The key's randomart image is:
+--[ RSA 2048]----+
| |
| o |
| o o |
| . .....o. |
| o..... ...|
| . o. . ..+.|
| .. ooooo|
+-----------------+
myhost@myhost-lap:~$ ssh user@targethost mkdir -p .ssh
user@targethost's password:
Then add the entries into the target host's autherized keys
myhost@myhost-lap:~$ cat .ssh/id_rsa.pub | ssh user@targethost 'cat >> .ssh/authorized_keys'
user@targethost's password:
Finally you could login like following without a password
myhost@myhost-lap:~$ ssh user@targethost
Reference http://linuxproblem.org/art_9.html