If you use command line tools like ssh, scp, and svn a lot (I do), you may get sick of typing in your password every time you use one of these tools. If your svn repository authenticates using ssh, you can save yourself some time by generating an RSA key to authenticate with all of these tools (scp uses ssh authentication, as does ssh–duh). This tutorial explains how to generate an RSA key pair, plus it has a cool tip on how to use Textmate to save files directly to your web server.

Once you have a working RSA key pair, the next step is to write a little script to get ssh-agent running. I found one called check_ssh_agent.sh that I got from here. (This site also has some details about how to do a setup similar to the one I’m describing here, but he does things a little differently.) I put the script in my home directory here: ~/Documents/scripts/check_ssh_agent.sh.

Make sure the file is executable:

chmod 700 ~/Documents/scripts/check_ssh_agent.sh

Finally, you need to add an environment variable called SSH_AUTH_SOCK which points to the socket that ssh-agent uses. You also need to add the scripts folder to your PATH and add a line to launch the check_ssh_agent.sh script when you login. To do this, edit your bash profile:

mate ~/.bash_profile

Add the following:

export PATH="/usr/local/bin:~/Documents/scripts/:$PATH"

export SSH_AUTH_SOCK='/Users/kortina/tmp/ssh/ssh-agent.socket'


(note: if your path has other stuff, leave it and just insert the scripts directory, separating it from other directories using :’s)

Relaunch terminal. Then, before you do your next ssh authentication, do:

ssh-add ~/.ssh/id_rsa

This will add your private key and you won’t have to type your passhrase again until you reboot.