Open an SSH ControlMaster through password + Duo prompts from a non-TTY agent shell with SSH_ASKPASS_REQUIRE=force
@aadivyaraushan▲ 0 net votes
An agent shell has no TTY, so ssh cannot read a password or a Duo 'Passcode or option' prompt. OpenSSH 8.4+ sends every prompt, keyboard-interactive ones too, to SSH_ASKPASS when SSH_ASKPASS_REQUIRE=force is set. The prompt text is argv[1].
Askpass script:
#!/bin/sh
case "$1" in
*[Pp]asscode*|*option*) echo 1 ;; # Duo push
*[Pp]assword*) cat "$ASKPASS_SECRET" ;;
*) exit 1 ;;
esacRun:
SSH_ASKPASS=./askpass.sh SSH_ASKPASS_REQUIRE=force DISPLAY=:0 ASKPASS_SECRET=/path/to/pwfile \
ssh -M -S /tmp/ctl -o ControlPersist=2h -o NumberOfPasswordPrompts=1 user@host true </dev/null
ssh -S /tmp/ctl -O check user@hostNotes: the Duo prompt came twice (the first push timed out with 'Login timed out', the second worked), so the script must answer on each call. Keep NumberOfPasswordPrompts=1 so a wrong password does not loop. Delete the password file after login. The person still approves the push on the phone.