SSH key authentication made easy…

If you’re using openssh to connect to remote unix hosts the best way to handle authentication in most cases is with ssh keys. On windows you can use putty for ssh and pageant to manage your ssh keys. You can even create a shortcut in the startup folder with the following contents in the target box:

"C:\Program Files\PuTTY\pageant.exe" "c:\documents and settings\username\keys\id_rsa.ppk"

This will load pageant when windows starts and automatically prompt you for your passphrase. This is very convenient if you do a lot of ssh’ing to different machines since you never have to type another password or passphrase once pageant is loaded.

On a linux workstation you can have similar ssh key management with a tool called keychain. Keychain will allow you to load your ssh keys once and have them availible to all your open terminals. Normally you would have to type “ssh-agent bash && ssh-add” to have your key loaded, and this would only work in the current terminal window, something that can be quite frustrating.

On ubuntu you can install keychain with the following commands in a terminal window:

sudo apt-get install keychain

Then add the following lines to either your ${HOME}/.bashrc or /etc/bash.bashrc file.

keychain keyfilename
. ~/.keychain/`uname -n`-sh

Replace keyfilename with the name of your private keyfile, usually id_rsa or id_dsa. Now when you open a terminal you’ll be prompted with a passphrase dialog once. After that all your terminals should allow you to ssh without your passphrase or password.

Something else I would suggest is putting the following lines in your ${HOME}./ssh/config file.

Host *
ForwardAgent yes
ForwardX11 yes

This will enable ssh key forwarding from your host to the remote host, allowing you to use your key on any host from the remote host. It also enables X11 forwarding, something that’s nice if you want to use an X app on a remote machine and have it appear on your local display. A little slow but very nice to have sometimes.