I decided to setup a small Linux box that would login to my Linux boxes to backup with rsync (will post how I did that later). In order to do this with a script I had to setup SSH to log me in without a password otherwise my script would prompt me for the password every time.

Remote Machine (Server)

First I had to login on the remote server and check to make sure in the file that /etc/ssh/sshd_config had the following uncommented:

RSAAuthentication yes
PubkeyAuthentication yes

Be sure to restart sshd after you make changes.

service sshd restart #redhat/CentOS
/etc/init.d/sshd restart #ubuntu/other

We will need to create a folder for SSH keys in your home directory so run this command:

[ -d ~/.ssh ] || mkdir ~/.ssh

This command will test to see if the .ssh directory is there, if not it will create it.

The next step is to secure that directory to make it readable only by you.

chmod 700 ~/.ssh

Local Machine (Client)

First check to see if the files ~/.ssh/id_rsa and ~/.ssh/ exist, if so you can skip the following command.  The command will generate a public/private key pair, it will ask you for a passphrase, do not put one in the key as it defeats the purpose of creating a passwordless login.

ssh-keygen -t rsa

Then run the following command and this will setup the password-less SSH login (it will ask you for your password once).

ssh-copy-id -i ~/.ssh/ username@remotehost

You are done!