SSHAgentStartup

| | Comments (0)
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;

use.perl.org

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on March 18, 2003 5:03 PM.

Bloom County was the previous entry in this site.

True War Objective Met is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.