Setup shared keys for passwordless ssh login

In this post I will show how I setup passwordless logins to my servers. This is especially useful when you want to do logins in a script e.g. a rsync script for backup to another computer through ssh

First we have to start with creating a private/public key pair on the computer that we will do the login from

ssh-keygen -t rsa -b 1024

I use default options here. NOTE: Do NOT set a passphrase. If you do then the key pair expects this passphrase every time you use it which means that you will not be able to make passwordless logins with this key pair. Just press Enter twice and the key pair will be created without a passphrase.

After a while the key pair is created and you should have a id_rsa and id_rsa.pub in your home .ssh directory

Now we need to get your public key (id_rsa.pub) to the server we want to login to

cat .ssh/id_rsa.pub | ssh <servername> "cat >> ~/.ssh/authorized_keys"

That is it! Now you should be able to login to the server without using a password. Try it with:

ssh <servername>

No password should now be asked for

Tested on Debian 5.0 (arm/pc) and OS X 10.6.8

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

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