SSHAgentStartup is a cool utility that properly starts up an ssh-agent and sets the environment variables for it in your ~/.MacOSX/environment.plist. It worked under Mac OS X 10.1, but broke under Jaguar, and I wrote my own pseudo-replacement, but was rewritten and now works again.
It doesn't set your shell environment, though; so I modified this to output to a file calles .bash_ssh_env, which I then source from .bash_profile.
--- SSHAgentStartupHelper.c.orig Wed Sep 4 05:49:33 2002
+++ SSHAgentStartupHelper.c Fri Mar 14 08:55:08 2003
@@ -135,9 +135,12 @@
}
}
-void startSSHAgent(CFMutableDictionaryRef plist) {
+void startSSHAgent(char* macosxdir, CFMutableDictionaryRef plist) {
// -s specifies bourne shell output
- FILE* output = popen("/usr/bin/ssh-agent -s", "r");
+ char cmd[PATH_MAX + 64];
+ snprintf(cmd, PATH_MAX + 64, "/usr/bin/ssh-agent -s | grep -v echo | tee %s/../.bash_ssh_env", macosxdir);
+
+ FILE* output = popen(cmd, "r");
if (output && plist) {
int i;
char* line;
@@ -193,7 +196,7 @@
}
}
if (plist) {
- startSSHAgent(plist);
+ startSSHAgent(macosxdir, plist);
writeEnvironmentPlist(aConfigFile, plist);
}
return 0;