How To Setup SSH Passwordless Login In Linux

For login to remote server without password you need to generate the ssh key. For ssh private/public key generation follow the below steps. The below article is clearly explain, how to generate the RSA ssh key and how to copy the ssh key to remote server.

1) How to generate SSH Private/Public key.

Use the below command to generate the RSA ssh key on your local server. Note that you are in local server.

# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): [Just, Press Enter Key]
Enter passphrase (empty for no passphrase): [Just, Press Enter Key]
Enter same passphrase again: [Just, Press Enter Key]
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
53:b7:3a:5b:39:22:78:35:e7:cf:44:64:cd:52:d4:a1 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|               o=|
|              .+.|
|          . .E+ o|
|         . . + . |
|        S o o .  |
|       . o = o   |
|      . o + = .  |
|       . . = =   |
|          .   o  |
+-----------------+

2) How to view generated SSH Private/Public key.

The private/public key has been generated and stored at “/root/.ssh/”. Go to the corresponding directory and see the generatd keys. See the output.

# cd /root/.ssh/
[[email protected] .ssh]# ll -h
total 12K
-rw------- 1 root root 1.7K Dec 18 13:01 id_rsa
-rw-r--r-- 1 root root  419 Dec 18 13:01 id_rsa.pub
-rw-r--r-- 1 root root 1.6K Aug 23 08:15 known_hosts

3) The id_rsa.pub key is below

Now, i’m going to print the id_rsa.pub details here.

# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0JOae6XhB1NccSrms4NpuLufOiMu10ObKoxWHtQ5oVXUvCuFz7Vxp5eKIGmizLtZoFxi3DOKcuVtP9FA5YMpqa6umEKAtJSIVgwZGBWvpkGElqvpP5r720f3XScpHkL/t/AnCPVeDn2jtL4XBkMDacOViD8m9P/TtQXthDqR3ZTtixsAXACm/bjLJKtUJUqrzTbM5LfQe7hh1xq8EyCXF6shvuXS/0GUvyjPhGPkhFGIjFrPwbWnw8qudzBIlbGEMhboVwDeqJohDd7nkd2Ww0VyBMplJwEs2VGdI/HNwHKXp2HNgbJBCkWvNe7Aq3YekV/aqgd7QPjasZf8OM1hAVjWoVw== [email protected]

4) Copy the public key to remote-host using ssh-copy-id

I’m using ssh-copy-id to copy the id_rsa.pub key to remote server.

# ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
The authenticity of host '82.165.133.65 (82.165.133.65)' can't be established.
RSA key fingerprint is 6f:ad:07:15:65:bf:54:a6:8c:5f:c4:3b:99:e5:2d:34.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '82.165.133.65' (RSA) to the list of known hosts.
[email protected]'s password:
Now try logging into the machine, with "ssh '[email protected]'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

Note :

The ssh-copy-id copy the id_rsa.pub key to remote server with name of authorized_key under “/root/.ssh/”.

5) Try access Remote server without Password

Now, you can access the remote host without entering password. like below

# ssh [email protected]
Last login: Wed Dec 18 13:00:57 2013 from 219.91.219.14
[[email protected] ~]#

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

Shares
Close
Please support the site
By clicking any of these buttons you help our site to get better