Back

Password Free SSH Howto

There are some occasions in the life of a system administrator that you need to set up automated actions to remote servers. Now, you could just set up the actions to take place on each server, but what if you need to handle all actions from a single server? The normal method for remote administration would involve the use of SSH, a nice secure manner to access a remote server. However, this doesn't help too much for cases of automated actions, as you need to enter a password for each connection. So how do we work around this? Read on!

Step 1: Generate a key

From the system you wish to connect from, run the following commands:

ssh-keygen -t dsa -f ~/.ssh/id_dsa

When asked for a password, press - you want this to be password free after all.

Copy over the id_dsa.pub file that will be created in ~/.ssh/ using whatever method you like - I use scp.

scp ~/.ssh/id_dsa.pub user@remotehostiwanttoconnectto:.ssh/id_dsa.pub

Step 2: Authorize the key

Now log into the remote server and do the following:

cd .ssh cat id_dsa.pub >> authorized_keys2 chmod 640 authorized_keys2 rm -f id_dsa.pub

This should work for cases of OpenSSH to OpenSSH servers.

Step 3: SSH2 only cases (optional)

You may need to do the following as well for cases where you have only SSH2 available:

On the local computer (client), run this command on your (still existing) id_dsa.pub file:

ssh-keygen -e -f .ssh/id_dsa.pub > id_dsa_ssh2.pub scp id_dsa_ssh2.pub user@remotehostiwanttoconnectto:

Log on to the remote server and:

cd ~ mkdir .ssh2 mv id_dsa_ssh2.pub .ssh2 cat id_dsa_ssh2.pub >> authorization chmod 640 authorization rm -f id_dsa_ssh2.pub

You should be good to go - Enjoy!

Back