From: Jamis Buck Date: 2004-09-11T23:28:38+09:00 Subject: Re: Net-SSH Threaded PortForward Script Problems I haven't actually tried running your script, but it looks to me like the problem is in your script that does the port forwarding: > BEGIN CODE 4 host Hop > ---------- > > #!/usr/local/bin/ruby > > require 'thread' > require 'net/ssh' > require 'net/ssh/service/forward' > > threads = [] > > > t = Thread.new do > Net::SSH.start( 'host1', 'jello', 'pass' ) do |session| > mgr = PortForwardManager.new( session ) > mgr.forward_local( 1234, 'host2', 22 ) > session.main_loop > end > end > > t = Thread.new do > Net::SSH.start( 'localhost', 1234, 'jello', 'pass' ) do |session| > mgr = PortForwardManager.new( session ) > mgr.forward_local( 1235, 'host3', 22 ) > session.main_loop > end > end > > t = Thread.new do > Net::SSH.start( 'localhost', 1235, 'jello', 'pass' ) do |session| > mgr = PortForwardManager.new( session ) > mgr.forward_local( 1236, 'host4', 22 ) > session.main_loop > end > end > > Net::SSH.start( 'localhost', 1236, 'jello', 'passwd' ) do |session| > result = session.exec("hostname") > puts result.data, "\n\n" > result = session.exec("date") > puts result.data, "\n\n" > result = session.exec("uptime") > puts result.data, "\n\n" > end > > threads.push( t ) > > --------- > END CODE You aren't doing a "join" on the threads, so the Ruby interpreter is exiting immediately--killing all running threads on the way. Which means none of the ports are being forwarded, which means your attempt to connect to a forwarded port fails with "connection refused." So, 1) make sure you add *each thread* to the threads array 2) make sure you join *each thread*, something like this: threads.each { |t| t.join } See if that helps. If it doesn't, post again and I'll see if I can dig deeper. - Jamis -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis "I use octal until I get to 8, and then I switch to decimal."