The ssh command doesn't read the password from STDIN, but from /dev/tty, and I suspect that all other password-prompting commands from the ssh suite do the same.
Use the sshpass command to provide passwords for ssh-* in a non-interactive way.
update: many password related programs work that way, e.g. the UNIX passwd utility. I have seen staggeringly stupid and highly dangerous attempts to work around this, e.g. a shell script to set passwords which moves away /dev/tty, writes a new plain file /dev/tty with two lines containing the password, invokes passwd and restores the original /dev/tty. It is big fun if any program opens /dev/tty during that sequence (e.g. less). So don't do that!
From the manual page of sshpass:
SECURITY CONSIDERATIONS
First and foremost, users of sshpass should realize that ssh's insistance on only getting the password interactively is not without reason. It is close to impossible to securely store the password, and users of sshpass should consider whether ssh's public key authentication provides the same end-user experience, while involving less hassle and being more secure.
Maybe that is an option for you?
In reply to Re: I am having a big difficulty with two way pipes from a system executed command (ssh)
by shmem
in thread I am having a big difficulty with two way pipes from a system executed command
by igoryonya
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |