I use the handy app SSHKeychain on my OS X box, which handles my SSH agent for me in various useful ways. The only problem is that the environment doesn't get set up properly for things like cron (since SSHKeychain stores it's socket info in a .plist).
This little snipped enables me to do things like:
with-sshkeychain svk sync -a 2>&1 | mail -s svk-sync-all adrianh
in my crontab and still get a connection to the SSHKeychain run ssh-agent. Super.
#! /usr/local/bin/perl
# with-sshkeychain SOME OTHER COMMAND
use Mac::PropertyList;
my $plist =
Mac::PropertyList::parse_plist_file(
"$ENV{ HOME }/.MacOSX/environment.plist" )
or die "cannot parse environment.plist\n";
$ENV{ SSH_AUTH_SOCK } = $plist->value( 'SSH_AUTH_SOCK' )
or die "no SSH_AUTH_SOCK\n";
exec( @ARGV );