Skip to content

Instantly share code, notes, and snippets.

@sinewalker sinewalker/
Last active Jan 3, 2019

What would you like to do?
ssh-pass: add an SSH key to your agent with passphrase from password store, no clipboard
#Add specified SSH keys to the SSH Agent, using SSH_ASKPASS to retrieve
#each key's passphrase from the Unix password store (pass).
#This relies upon the keys having the same names in both your key directory
#and your password store.
if [[ -z ${1} ]]; then
echo "$(basename ${0}): no SSH key specified" 1>&2
exit 1;
export DISPLAY=dummy
for KEY in ${@}; do
export SSH_ASKPASS=$(mktemp -t ssh-askpass)
cat > ${SSH_ASKPASS} << EOF
pass ${KEY}|head -1
chmod +x ${SSH_ASKPASS}
ssh-add ${KEY_DIR}/${KEY} < /dev/null

This comment has been minimized.

Copy link
Owner Author

commented Jan 3, 2019

Blogged at, and since improved a bit by adding the for loop to handle multiple keys (each still has the same naming constraint).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.