Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created August 24, 2020 14:13
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 wpsmith/11f1a164dff92622cdd1492fc5003218 to your computer and use it in GitHub Desktop.
Save wpsmith/11f1a164dff92622cdd1492fc5003218 to your computer and use it in GitHub Desktop.
Shell: Reads a passcode.
#!/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