dotfiles/bin/lp-ssh-add
2018-02-26 12:45:54 +01:00

23 lines
408 B
Bash
Executable file

#!/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