Skip to content

Instantly share code, notes, and snippets.

@electrum
Created January 17, 2013 20:06
Show Gist options
  • Save electrum/4559248 to your computer and use it in GitHub Desktop.
Save electrum/4559248 to your computer and use it in GitHub Desktop.
#!/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 -k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment