Saturday, May 23, 2009

Configure SSH to connect without entering password

This blog post is not about hacking into another's machine without the proper authorization of the owner. If you are looking for that, this is not the right place.

This is about configuring the SSH without entering the password, but, with the proper authorisation of the machine owner :). In cluster computing quite often, it is required to do this. This article describes how to do it by using "DSA" encryption algorithm. It is quite possible to use "RSA" encryption too.

Say there are two machines called A and B. Now we are going to configure machine A to connect to machine B without entering the password of machine B.

Generate private and public keys for the machine A.
ssh-keygen -t dsa

The ssh-keygen command will ask you to enter a passphrase. In this case it should be empty in order to connect without entering a password to the machine B.

The above command will place the private key file (id_dsa) and the public key file (id_dsa.pub) in the ".ssh" directory in the home directory of your user account.
Then copy the public key of machine A to the ".ssh/authorized_keys" file resides in the home directory of the machine B.

Now, you can connect to the ssh server of machine B from machine A without entering a password/passphrase.
In a cluster environment, you have to configure ssh in such a way that it enables to connect each others' ssh servers.

NOTE: It is not recommended to leave a passphrase empty when creating the keys. But, for the situations like clusters who comunicates via ssh, passphrase should be kept empty.

No comments:

Post a Comment