Last active
January 13, 2017 10:14
-
-
Save jolbax/cd2c63c0249f8595917b831425ac765a to your computer and use it in GitHub Desktop.
How to make ssh-add read passphrase from a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -ne 2 ] ; then | |
echo "Usage: ssh-add-pass keyfile passfile" | |
exit 1 | |
fi | |
eval $(ssh-agent) | |
pass=$(cat $2) | |
expect << EOF | |
spawn ssh-add $1 | |
expect "Enter passphrase" | |
send "$pass\r" | |
expect eof | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment