CirclingMinds

May 6, 2007

Public Key Authentication

Filed under: linux — shovan @ 9:59 pm

Using public key authentication you can save yourself the hassel of remembering and entering password everytime you try to connect to a remote server. This process requires two files: a private key and a public key that identifies the local machine and the remote host.  Lets get started.

Step 1:

Enter the following command on the local machine.

ssh-keygen -t dsa

It will ask you if you want to enter a pass phare. Ignore it.

That command creates two files

i) id_dsa : This is the private key
ii) id_dsa.pub : public key which you will copy to the remote host where u want to login using the public key authentication method
Step 2:

Copy the id_dsa.pub key to the remote host you want to access.

Step 3:

Log in to the remote host and add the id_dsa.pub file to the authorized_keys file which resides in your ~/.ssh/ directory. If the file and the directory does not exist then you have to create it.

Syntax for adding the public key (id_dsa.pub) to the authorized_keys file:

cat id_rsa.pub > authorized_keys

Now try logging into the remote host. You will notice that you no longer require password to get in. This is because your machine’s public key  is listed in the authorized_keys file that matches to your corresponding id_dsa private key that is located in your ~/.ssh folder.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress