Last active
March 7, 2021 16:04
-
-
Save georgjaehnig/217c004decb58877a2eebd05788d1dee to your computer and use it in GitHub Desktop.
Add an encrypted SSH key with `ssh-add` and get the password from `pass` (passwordstore.org)
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 | |
# Script adapted from | |
# https://stackoverflow.com/a/13034313 | |
# | |
# Requirements: | |
# - "expect" https://linux.die.net/man/1/expect | |
SSH_KEY_FILE="FULL_PATH_TO_SSH_FILE" # example: "/Users/alice/.ssh/id_rsa" | |
PASS_NAME="NAME_OF_FILE_IN_~/.password-store" # example: "my-ssh-passphrase" | |
pass=$(pass show "${PASS_NAME}") | |
expect << EOF | |
spawn ssh-add "${SSH_KEY_FILE}" | |
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