Steps to ssh login into remote server without entering password. ssh-keygen creates the public and private keys. ssh-copy-id copies the local-host’s public key to the remote-host’s authorized_keys file. ssh-copy-id also assigns proper permission to the remote-host’s home, ~/.ssh, and ~/.ssh/authorized_keys.
1) Create public and private keys using ssh-keygen
thangaraj@thangaraj-Insp:~$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/thangaraj/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/thangaraj/.ssh/id_dsa.
Your public key has been saved in /home/thangaraj/.ssh/id_dsa.pub.
The key fingerprint is:
ee:12:23:ca:dd:7f:10:5f:e3:30:43:24:03:ff:d1:68 thangaraj@thangaraj-Insp
2) Copy the public key to remote-host using ssh-copy-id
thangaraj@thangaraj-Insp:~$ ssh-copy-id -i ~/.ssh/id_dsa.pub root@remote-host [or enter ip address instead of host name, i.e, remote-host]
root@remote-host’s password:
Now try logging into the machine, with “ssh ‘root@remote-host'”, and check in:
~/.ssh/authorized_keys
to make sure we haven’t added extra keys that you weren’t expecting.
3) Login to remote-host without entering the password
thangaraj@thangaraj-Insp:~$ ssh root@remote-host [It wont ask password to login into remote machine]