views:

163

answers:

0

Hello,

I'm accessing a remote database using a local-to-remote port forwarding from my windows box. It works like a charm using putty for port forwarding but it fails when I try to forward using Ruby/Net::SSH. Here is my code snippet:

require 'rubygems'
require 'net/ssh'

Net::SSH.start(remote_host, user_name, :password => password) do |ssh|
  ssh.logger.sev_threshold=Logger::Severity::DEBUG
  ssh.forward.local(5555, 'www.google.com', 80) # works perfectly
  ssh.forward.local(4444, remote_host, 1234)    # db connection hangs up
  ssh.loop { true }
end

The port forward to google.com works fine when tested with a browser. The port forward to my linux server, where my db server is listening on port 1234, isn't working. When I try to connect to localhasot:4444 the connection hangs up. Logs:

DEBUG -- net.ssh.service.forward[24be0d4]: received connection on 127.0.0.1:4444
DEBUG -- tcpsocket[253ba08]: queueing packet nr 6 type 90 len 76
DEBUG -- tcpsocket[24bde64]: read 8 bytes
DEBUG -- tcpsocket[253ba08]: sent 100 bytes
DEBUG -- net.ssh.connection.channel[24bdcc0]: read 8 bytes from client, sending over local forwarded connection

And then nothing!

I'm using net-ssh 2.0.22 / ruby 1.8.7

Thank you in advance --Chaker