You are here

Howto: Automatic OS X Leopard ssh-agent

Update: March 9, 2010

Somehow I failed to notice that since 10.5 ssh agent is automatically started by OS X. My script just duplicated work that was already built-in to the OS.

To add a passphrase for a private key just type:

ssh-add -K keyfile_rsa

After this, ssh-agent is started automatically whenever ssh needs it. No extra work needed.

Comments

I found that the "sudo touch /var/db/useLS" command given at http://www-uxsup.csx.cam.ac.uk/~aia21/osx/leopard-ssh.html with a reboot worked for me. The site says that you don't need the touch with Leopard, but with Snow Leopard it didn't work for me until I did it. HTH

You can also make a shell alias which adds your key to ssh-agent when ssh is called. I find this preferable to storing your private key password in the Keychain. I use tcsh, so this alias does the trick:

alias ssh 'if (`ssh-add -l` == "The agent has no identities.") ssh-add; /usr/bin/ssh'