Skip to content

Instantly share code, notes, and snippets.

@fclairamb
Last active December 15, 2015 20:29
Show Gist options
  • Save fclairamb/5319221 to your computer and use it in GitHub Desktop.
Save fclairamb/5319221 to your computer and use it in GitHub Desktop.
Add an SSH key with a password automatically. This can be added to bashrc for instance.
/usr/bin/expect >/dev/null <<EOF
set password mypassword
set key mykey.pub
spawn ssh-add /home/user/.ssh/$key
match_max 100000
expect ":"
send -- "$password\r"
expect eof
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment