I don’t actually need to run the command below, and I am aware of ssh keys if I did want to log in without typing a password. I would just like to know how ssh
seems to circumvent my file redirection.
Running the following command, ssh
prompts me for a password:
ssh [email protected] > /dev/null 2> /dev/null < /dev/null
How does this work? stdin
, stdout
, and stderr
are all redirected, but ssh
still manages to print a prompt on my screen and read what I type. I tried adding the ssh
arguments -t -t
and -T
(not both at once), to enable or disable pseudo-tty allocation, but it made no difference.
I also tried closing all input and output this way, although I don’t know if I typed it correctly. Still, ssh
prompts for a password:
(exec 0<&- 1<&- 2<&- 0>&- 1>&- 2>&-; ssh [email protected])
-o PasswordAuthentication=no
, and consider the-n
option.