Skip to content

Instantly share code, notes, and snippets.

@kabouzeid
Last active April 21, 2023 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kabouzeid/9b2744bd2e783ff66847135335b00fa8 to your computer and use it in GitHub Desktop.
Save kabouzeid/9b2744bd2e783ff66847135335b00fa8 to your computer and use it in GitHub Desktop.
Launch agent to add ssh keys to the agent on login.
<?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>codes.ka.ssh-add-keychain</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/ssh-add</string>
<string>--apple-load-keychain</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
@kabouzeid
Copy link
Author

kabouzeid commented Apr 21, 2023

Move into ~/Library/LaunchAgents to load on login.


This adds all key's to the ssh-agent. Note that the ssh command already does that when AddKeysToAgent yes is set, but other commands, such as git commit -S, do not. So after a reboot, when you git commit -S before using ssh for the first time, it will not work and instead fail with error: Load key "/var/folders/[...]/.git_signing_key_tmp[...]": invalid format?. This launch agent fixes that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment