Monday, January 5, 2009

SSH: Logging without Passwords

Here is what to do :-

1. generate a public and private key pair.

ssh-keygen -t rsa -b 4096 -C "comment"

This would generate a 4096 bit long key using RSA encryption mechanism. You can choose to use DSA instead of RSA.

2. When prompted save the key to your home directory.
In my case it would be /home/nemesis/.ssh/id_rsa.pub

3. When prompted for a passphrase, just press enter. Press enter to confirm again. This means a blank password.

4. scp the above generated password file to the remote server.
e.g scp /home/nemesis/.ssh/id_rsa.pub nemesis@remote-server.org:/home/nemesis/

where remote-server.org is the remote machine that I want to login to without using passwords.

5. ON THE Remote machine now.

>Check to see if there is a .ssh folder. If it doesnt exist in your home directory, create it

mkdir -p /home/nemesis/.ssh

Now add your credentials to the authorized lists. Here is how to do it.

cat id_rsa.pub >> .ssh/authorized_keys

6.Logout

7. ssh nemesis@remote-server.org
Voila!!! You are in. No password required.

No comments: