How To Ssh Without Password Linux



In your practice you may need perform ssh without password in linux or you may need to do passwordless scp between two linux machines. For that you need to setup an ssh auto login password between two servers. You can perform passwordless scp and passwordless ssh, by configuring ssh auto login password.

Perform the below steps to configure ssh passwordless login in linux. Here, i am explaining the password less connection between two nodes, server1 and server2.

Ssh Without Password Linux:

Connect to server1 and run the below commands as a administrative user to establish the ssh connection without password from server1 to server2.

Step1: Run the below command as administrative user with which you want to make passwordless ssh connection. Hit Enter button when it prompts. Here am establishing ssh as oracle user.

Syntax: ssh-keygen -t rsa

[[email protected] ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_rsa): Enter⏎

Created directory ‘/home/oracle/.ssh’.

Enter passphrase (empty for no passphrase): Eneter⏎

Enter same passphrase again: Eneter⏎

Your identification has been saved in /home/oracle/.ssh/id_rsa.

Your public key has been saved in /home/oracle/.ssh/

The key fingerprint is:

e6:fa:f6:92:0e:c9:50:b0:b2:03:a3:5a:a8:1c:58:1c [email protected]

The key’s randomart image is:

+–[ RSA 2048]—-+

|  E .            |

| . . o           |

|o + . .          |

|o= o .           |

|+.+ .   S        |

|+… o +         |

|o.    + ..       |

|       o+        |

|      .+oo.      |


[[email protected] ~]$

Step2: After generating public/private keys run the below command. Here Replace the IP address with your destination server IP(Here server2 for me). Enter the password for destinations server administrative user.

Syntax: ssh <Hostname / IP address> mkdir -p .ssh

[[email protected] ~]$ ssh mkdir -p .ssh

[email protected]’s password:

[[email protected] ~]$

Step3: Now run the below command and enter the password for destination server user to copy authorized keys.

Syntax: cat .ssh/ | ssh <hostname / IP address> ‘cat >> .ssh/authorized_keys’

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

[email protected]’s password:

[[email protected] ~]$

Step4: Now the below command to give the pemissions on authorized keys and enter the password when it prompts.

Syntax: ssh < hostname / IP address> “chmod 700 .ssh; chmod 640 .ssh/authorized_keys”

[[email protected] ~]$ ssh “chmod 700 .ssh; chmod 640 .ssh/authorized_keys”

[email protected]’s password:

[[email protected] ~]$

Step5: Now verify the ssh passwordless login by making ssh connection from server1 to server2.

Syntax: ssh <hostname / IP address>

[[email protected] ~]$ ssh

Last login: Thu Feb 23 18:56:38 2017

[[email protected] ~]$

Now you are success fully completed ssh passwordless login. If you want make ssh passwordleass login from server2 to server1, then repeat the same 4 steps from server2.