-
-
Save bcopeland/3cabf6ff3fe94fcbd566 to your computer and use it in GitHub Desktop.
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/sh | |
# | |
# Import all SSH keys from LP | |
# | |
PREFIX=~ | |
SSH_ASKPASS=$PREFIX/bin/lp-askpass.sh | |
export SSH_ASKPASS | |
# This is needed to force ssh-add to honor our SSH_ASKPASS. | |
DISPLAY=foo | |
export DISPLAY | |
CONTAINER="Secure Notes\SSH" | |
# For some reason, lpass ls includes the folder's ID | |
CONTAINER_ID=4532168026 | |
for key_id in `lpass ls "${CONTAINER}" | grep -v $CONTAINER_ID | awk '{print substr($4, 0, length($4))}'`; do | |
KEY_ID=$key_id | |
export KEY_ID | |
# setsid is needed to force ssh-add to honor our SSH_ASKPASS. | |
$PREFIX/lpass show --field "Private Key" $key_id | setsid ssh-add /dev/stdin | |
done |
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/sh | |
PREFIX=~/bin | |
if [ -z "$KEY_ID" ]; then | |
exit 1 | |
fi | |
$PREFIX/lpass show --field Passphrase $KEY_ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So I can't use the
Private Key
/Public Key
fields because of https://forums.lastpass.com/viewtopic.php?f=7&t=94925 . The problem is that if you use the web UI, you can paste the full key in but it converts all carriage returns to spaces (thus corrupting the ASCII-armor). If I uselpass edit
to edit the field, it only saves the first line. These 2 fields need to be made multi-line to be useful.