Can someone explain why SSH duplicates stdin back to to the screen when PTY allocation is forced and how I can disable it?
~% ssh -V
OpenSSH_5.5p1 Debian-6+squeeze2, OpenSSL 0.9.8o 01 Jun 2010
~% echo "This should only show up once." | ssh server.tld -tt '/bin/cat'
This should only show up once.
This should only show up once.
This actually turned out to be a pretty simple fix that I feel silly for overlooking. When you use
-tt
with SSH, SSH creates a pty but leaves the echo functionality enabled. To keep the text from being echoed back, prefix the command withstty -echo
like so:ssh -t server.tld "stty -echo && command"
I'm going to take a long shot here and guess that this is the local echo of the pty that you allocated. STDIN is being treated as the input of your terminal which is then being echoed back to you.
Off the top of my head I can't think of a sane way to deal with this, and I'm honestly inclined to say that it's not a good idea to try to do this anyway.
If you reply with a comment on why you feel that you must implement something this way, I will try to help you find an alternative solution out of band. I do not think that it will change this answer, however.