How to enable key based login in Linux

Following steps will ensure that you can do a ssh/scp command without giving password everytime:

Suppose you have to login from A to B

1. On A:

#ssh-keygen

This will generate a key.

2. On A:

#ssh-copy-id -i ~/.ssh/id_rsa.pub <IP of B>

You IP must be different from the above e.g.

#ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.1.51

You will be asked the password of B. I have assumed that ssh port is default, i.e. 22

3. On A:

Test that you have successed by running following command

#ssh <IP of B> e.g.

#ssh 192.168.1.51

You can see that we didn't do anything on B.

4. Enjoy !!!!!!!! 

Comments