in reply to I am having a big difficulty with two way pipes from a system executed command

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?

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
  • Comment on Re: I am having a big difficulty with two way pipes from a system executed command (ssh)
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: I am having a big difficulty with two way pipes from a system executed command (ssh)
by igoryonya (Pilgrim) on Nov 07, 2015 at 07:21 UTC
    Well, the automatic public key installation is what I want to achieve on the LAN, so I've tried to call ssh-copy-id to the remote pc, which asks for the password and doesn't have an option to pass password by cli.
    I am considering to reimplement the needed ssh-copy-id's functionality in perl, by using Net::SSH2 module, but before that, I wonder, if there is a way to, instead of using /dev/tty trick, emulate the keyboard to send the keys to the program. Make a perl program to act as if the keyboard would send the keys to the program, like you can do in the GUI programming, to send keyboard keystrokes.