Friday, June 14, 2013

ssh Password Less Login

Follow the below steps to perform the ssh passwordless login,

1.Login to the Server and run the below to generate the Key pair.

Sri> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sri/.ssh/id_rsa):
Created directory '/home/sri/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/sri/.ssh/id_rsa.
Your public key has been saved in /home/sri/.ssh/id_rsa.pub.
The key fingerprint is:
7y:74:10:98:25:06:17:d7:49:b7:u2:46:2i:jc:10:92 sri@beetle
The key's randomart image is:
+--[ RSA 2048]----+
|          ++B=oo=|
|         oE+..+.*|
|        . o  o = |
|         . o  . o|
|        S + .  . |
|         . o     |
|                 |
|                 |
|                 |
+-----------------+

2. The Private Keys gets genenrated .The Public Key gets created in the "/home/sri/.ssh/id_rsa.pub". 

Sri> cat /home/sri/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAouNqZ7+sK0P2zjf+y6pM1CY4jCZTD+CVzfjYyiAB7VhpIkn70MiPiNcbbrNCmIr4v+9U64Mm4ioAz9V4WJOhZ6+1/QLMhPpIhZcq7D1wfc26xU/b4moyzzygX8WaNd2D1XRX5JZMEcz/ir4C6wTFG9lL9Y9iKkKK2/sJHYGCDHJemxsw9wY4gH1fvrfdY/1M/rG4OOMrHsp9s6PB+1v+G7lEIHozDkPBDZx0ypSM4YNKZR6ddPt+GpcWU0RlS9X0eMeFljtWawmr1W90p/KeqwxQaVhl6YVZnQw1dJ0T5YUQIEhQcHJdJpbOfkN962D8dGJYGnjnTN2vJw83xoB/CQ== sri@beetle

3.To perform the Login without the Password copy the Public Key content (output is One line ) to the ".ssh/authorized_keys" on the remote System .
   The copy to the remote system can be done using scp or you can use the ssh as below

Sri> ssh remote -l sri "echo ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAouNqZ7+sK0P2zjf+y6pM1CY4jCZTD+CVzfjYyiAB7VhpIkn70MiPiNcbbrNCmIr4v+9U64Mm4ioAz9V4WJOhZ6+1/QLMhPpIhZcq7D1wfc26xU/b4moyzzygX8WaNd2D1XRX5JZMEcz/ir4C6wTFG9lL9Y9iKkKK2/sJHYGCDHJemxsw9wY4gH1fvrfdY/1M/rG4OOMrHsp9s6PB+1v+G7lEIHozDkPBDZx0ypSM4YNKZR6ddPt+GpcWU0RlS9X0eMeFljtWawmr1W90p/KeqwxQaVhl6YVZnQw1dJ0T5YUQIEhQcHJdJpbOfkN962D8dGJYGnjnTN2vJw83xoB/CQ== sri@beetle  >>~/.ssh/authorized_keys"

Enter the password when its prompted and the authorised_keys of Remote system is updated and now you can login without Password to the remote system.

No comments:

Post a Comment