Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I've got a command that I'm issuing that is essentially 'ssh'ing into various hosts:

 command 2&>1 | grep "desired output" 

Every once in a while, in the midst of the command, it'll run into a host where I don't have my keys setup. When that happens, I get this output:


Since I'm redirecting STDERR into STDOUT, then filtering STDOUT to only give me "desired output" (which doesn't include "Password:"), how is the password prompt being presented to me?

share|improve this question
up vote 6 down vote accepted

ssh opens /dev/tty for read and write to prompt for the password.

I guess this a security feature, the input has to be from the tty rather than stdin.

If you run strace ssh <host> strace will show you the system calls the command is making.

I get:

open("/dev/tty", O_RDWR|O_LARGEFILE)    = 4
write(4, "dave@host"..., 16dave's password: ) = 16
share|improve this answer
From my understanding that's also the reason, why you can't simply pass the password to ssh from a script with a redirect. You'll need expect ( and see also…) – mpy Mar 21 '13 at 15:04
Terrific. I didn't think to dig in and strace it, since it was a passing curiosity, but thanks for that. I'm sure the knowledge will come in useful! – Matt Simmons Mar 21 '13 at 15:08
@terdon - the command you want (I think) is in the middle of the answer posted by parkydr: strace ssh <host> – Kevin Fegan Mar 21 '13 at 18:22
@KevinFegan thanks, I know. The post has been edited since I posted my comment. Check the editing log. – terdon Mar 21 '13 at 18:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.