# Net SSH Problem?

**URL:** <https://www.ruby-forum.com/t/net-ssh-problem/193652>\
**Category:** Ruby\
**Created:** [August 21, 2010, 12:51am UTC](https://www.ruby-forum.com/t/net-ssh-problem/193652 "2010-08-21T00:51:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [August 21, 2010, 12:51am UTC](https://www.ruby-forum.com/t/net-ssh-problem/193652/1 "2010-08-21T00:51:00Z")

</div>

Today I get to jump in to the net::ssh gem to start using it to control  
remote linux boxes. Loaded up the rubyforge page here:  
[http://net-ssh.rubyforge.org/ssh/v2/api/index.html](http://net-ssh.rubyforge.org/ssh/v2/api/index.html)

and checked out some examples. Tried out the example on my own like so:

require “rubygems”  
require “net/ssh”

opts = {}  
opts[:password] = #omitted, but triple-checked for correctness

#actual server, user names omitted to protect the innocent  
sess = Net::SSH.start “[my.server.com](http://my.server.com)”, “my\_user”, opts

#this works fine, outputting my\_user’s home dir  
rslt = sess.exec!(“pwd”).strip  
p rslt

#Here, “…in the block” never prints  
sess.exec “pwd” do |ch, stream, data|  
p “…in the block”  
if stream == :stderr  
p “Error: #{data}”  
else p data  
end  
end

Why doesn’t the block ever start? It’s almost exactly the same as the  
example on rubyforge?

Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![asoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/58956e/32.png) [@asoto](https://www.ruby-forum.com/u/asoto)\
**Post date:** [August 21, 2010, 4:12am UTC](https://www.ruby-forum.com/t/net-ssh-problem/193652/2 "2010-08-21T04:12:21Z")

</div>

This works here…

require “rubygems”  
require “net/ssh”

opts = {}  
opts[:password] = #omitted, but triple-checked for correctness

#actual server, user names omitted to protect the innocent  
sess = Net::SSH.start(“snip”, “snip”, opts)

#this works fine, outputting my\_user’s home dir  
rslt = sess.exec!(“pwd”).strip  
p rslt

#Here, “…in the block” never prints  
sess.exec “pwd” do |ch, stream, data|  
p “…in the block”  
if stream == :stderr then p “Error: #{data}”  
else p data end end

#==================================  
MarkT
