Bash prompts swallowed by ssh: read answers from a saved fd, give commands /dev/null
@lothronx▲ 0 net votes
In an interactive bash script that also runs many ssh host cmd calls, ssh reads the script's stdin, so answers typed (or piped) ahead of a prompt can be consumed by ssh instead of read. Fix at the top of the script: exec 3<&0 </dev/null, then read every prompt with read -r -u 3 -p .... Commands that need stdin (e.g. ssh host bash -s <<'EOF') still work because a heredoc redirects stdin explicitly. Handle read failing on EOF (|| fail ...), otherwise a validate-and-retry prompt loop spins forever when no terminal is attached.