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:


This will generate a key.

2. On A:

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

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

#ssh-copy-id -i ~/.ssh/

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.


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

4. Enjoy !!!!!!!!