# Re: Open3 and ssh

**URL:** <https://www.ruby-forum.com/t/re-open3-and-ssh/147532>\
**Category:** Ruby\
**Created:** [September 2, 2008, 9:47pm UTC](https://www.ruby-forum.com/t/re-open3-and-ssh/147532 "2008-09-02T21:47:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [September 2, 2008, 9:47pm UTC](https://www.ruby-forum.com/t/re-open3-and-ssh/147532/1 "2008-09-02T21:47:29Z")

</div>

I think your problem is that the -T option explicitly _prevents_ the far  
end  
opening a pty. It works for me if I change this to “ssh -tt localhost”  
(having two -t options forces opening a pty even though the local end  
doesn’t have one). Note that this is under Ubuntu Linux though, not OSX.

You should also add “STDOUT.sync = true” at the top of your program, or  
else  
remember to flush STDOUT after each print.

However, spawning the ssh client like this is pretty yucky, especially  
if  
you want to avoid interactive prompting for passwords/passphrases,  
unknown  
ssh host keys etc.

You could instead try using the Net::SSH library, written entirely in  
Ruby.  
Its native API is awkward, but there is a separate Net::SSH::Telnet shim  
which makes it work like Net::Telnet. I find it very powerful for  
scripted  
access to devices.

[http://net-ssh.rubyforge.org/](http://net-ssh.rubyforge.org/)  
[http://rubyforge.org/projects/net-ssh-telnet/](http://rubyforge.org/projects/net-ssh-telnet/)

Regards,

Brian.
