Last active
February 9, 2024 22:10
-
-
Save sinewalker/91d74a0d19a93f373e2071e5ba2ced2e to your computer and use it in GitHub Desktop.
ssh-pass: add an SSH key to your agent with passphrase from password store, no clipboard
This file contains hidden or 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 | |
| #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; | |
| fi | |
| KEY_DIR=${HOME}/key | |
| export DISPLAY=dummy | |
| for KEY in ${@}; do | |
| export SSH_ASKPASS=$(mktemp -t ssh-askpass) | |
| cat > ${SSH_ASKPASS} << EOF | |
| #!/bin/sh | |
| pass ${KEY}|head -1 | |
| EOF | |
| chmod +x ${SSH_ASKPASS} | |
| ssh-add ${KEY_DIR}/${KEY} < /dev/null | |
| rm ${SSH_ASKPASS} | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Automatically load ssh keys :
Add to .bashrc and configure environment variable.
My pass ssh entries:
$ pass _ssh/