SSH Login without password

http://www.linuxproblem.org/art_9.html

Basically you add the content of your own ~/.ssh/id_rsa.pub to the targets ~/.ssh/authorized_keys file.

(Replace ‘a’ with your username, A with your hostname or ip-address. Then replace b with your username on the remote computer, and B with the remote computers hostname or ip-address)

Normally you have the same username on both computers (but you don’t have too!) and different passwords. By enabling passwordless login, you don’t have to remember the different passwords.

We assume that SSH is installed and working (ports, firewall) on both computer A and B.

Do this to enable access by user a@A  to to machine B

Start by making sure that the ~/.ssh directory exists on the remote computer

a@A:~> ssh b@B mkdir -p .ssh
b@B's password: 

Then you append a’s new public key to b@B:.ssh/authorized_keys and enter b’s password one last time:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:

You can of course add the contents of your id_rsa.pub file to the remote targets ‘.ssh/authorized_keys’ file using any tool of your choice, but the above method is pretty failsafe.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.