Add lastpass ssh key convenience script
This commit is contained in:
parent
4f0cfb9d1f
commit
5a705f4f91
1 changed files with 23 additions and 0 deletions
23
bin/lp-ssh-add
Executable file
23
bin/lp-ssh-add
Executable 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
|
Loading…
Add table
Reference in a new issue