1
0
ssh-askpass-pinentry/ssh-askpass

42 lines
707 B
Bash

#!/bin/zsh
PINENTRY=@pinentry_mac@/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac
function send() {
print -p "$@"
read -p
}
function getpin() {
send GETPIN
test "${REPLY:0:3}" = ERR && { coproc : ; exit 1 }
echo ${REPLY:2}
}
coproc $PINENTRY
PINENTRY_PID=$!
trap "kill -TERM $PINENTRY_PID" INT TERM
read -p
send SETDESC $@
send SETPROMPT Password:
case "$@" in
"Confirm user presence"*)
send SETOK Hide
send CONFIRM --one-button
;;
*PIN*)
send SETPROMPT PIN:
send OPTION allow-external-password-cache
send SETKEYINFO ssh-askpass-pin
getpin
;;
*)
getpin
;;
esac
# Close the coproc
coproc :