Skip to main content

How to automatically log in to remote ssh servers using public/private keypair

As a user:

~>ssh-keygen -t dsa

and enter your way through the prompts

The keys are stored in the .ssh/ directory in your home directory.

-rw-------  1 pm users  668 2009-10-24 15:58 id_dsa
-rw-r--r--  1 pm users  601 2009-10-24 15:58 id_dsa.pub

id_dsa.pub is the public keyfile we are gonna place on the remote server.

ssh-copy-id -i ~/.ssh/id_dsa.pub remoteserver

Enter your password for the remote server.

You should get:

Now try logging into the machine, with "ssh 'remoteserver'", and check in:
 .ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.

Now try it for yourself:

ssh remoteserver

Et voila!