24 lines
408 B
Text
24 lines
408 B
Text
|
#!/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
|