How to setup password-less SSH Login

Are you tired of typing the password every time you want to login to the remote server? Setting up a password-less will make your life easier. Here’s how:

From your local machine run this:

$ ssh-keygen

You will see similar below, just follow the prompt to generate the key file.

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/atran/.ssh/id_rsa):
Created directory '/home/atran/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/atran/.ssh/id_rsa.
Your public key has been saved in /home/atran/.ssh/
The key fingerprint is:
37:36:1e:51:af:67:fa:85:e3:fe:5b:0f:bb:e8:c7:10 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|            .    |
|           . .   |
|          .   .  |
|           .E.   |
|        S * ..o  |
|         + +.+ . |
|          . .o+ o|
|             +o=o|
|           .oo*++|

Copy the generated key to the remote server that you want to setup password-less login:

$ cat ~/.ssh/ | ssh [email protected] 'cat >> ~/.ssh/authorized_keys'

Now try to login to the remote server, you should not be asked for password.