Skip to content

Instantly share code, notes, and snippets.

@grahams
Last active August 29, 2024 18:55
Show Gist options
  • Save grahams/71cf7fa00746c36ea40db09401ba1b94 to your computer and use it in GitHub Desktop.
Save grahams/71cf7fa00746c36ea40db09401ba1b94 to your computer and use it in GitHub Desktop.
Creates an LaunchAgent which correctly sets the SSH_AUTH_SOCK for all processes
mkdir -p ~/Library/LaunchAgents
cat << EOF > ~/Library/LaunchAgents/com.dosburros.SSH_AUTH_SOCK.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.dosburros.SSH_AUTH_SOCK</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/bin/ln -sf $HOME/.ssh/agent.sock \$SSH_AUTH_SOCK</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF
launchctl load -w ~/Library/LaunchAgents/com.dosburros.SSH_AUTH_SOCK.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment