Skip to content

Instantly share code, notes, and snippets.

@electrum
Created June 18, 2014 15:56
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 electrum/5e335e346e12b046f103 to your computer and use it in GitHub Desktop.
Save electrum/5e335e346e12b046f103 to your computer and use it in GitHub Desktop.
Add SSH certificate and keys to agent from Mac OS X keychain
#!/bin/sh -eu
FILE="$HOME/.ssh/id_rsa"
NAME="SSH: $FILE"
PASSWORD=$(security find-generic-password -w -l "$NAME")
expect << EOF
spawn ssh-add $FILE
expect "Enter passphrase"
send "$PASSWORD\r"
expect eof
EOF
ssh-add -A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment