1
0
ssh-askpass-pinentry/ssh-askpass

42 lines
707 B
Plaintext
Raw Permalink Normal View History

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