Add lastpass ssh key convenience script

This commit is contained in:
Daniel Lundin 2018-02-26 12:45:54 +01:00
parent 4f0cfb9d1f
commit 5a705f4f91

23
bin/lp-ssh-add Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
set -e
if [[ "$SSH_ASKPASS" == $0 ]]; then
exec lpass show --field Passphrase $_KEYID
fi
if [[ -z "$1" ]]; then
lpass ls --color=never ssh | cut -d ' ' -f1 | fzf | xargs -n1 $0
exit 0
fi
_tmp=$(mktemp -d)
cd $_tmp
mkdir -p $(dirname $1)
ln -s /dev/stdin $1
function cleanup {
rm -rf $_tmp
}
trap cleanup EXIT
lpass show --field='Private Key' $1 | SSH_ASKPASS=$0 _KEYID=$1 ssh-add $1