我正在使用本地到远程端口转发从我的Windows框中访问远程数据库。它像使用putty进行端口转发的魅力一样工作,但当我尝试使用Ruby/Net :: SSH转发时,它失败。这里是我的代码片段:使用Ruby/Net :: SSH进行远程数据库连接的本地到远程端口转发
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
转发到google.com的端口在使用浏览器进行测试时工作正常。 端口转发到我的Linux服务器,我的数据库服务器正在侦听端口1234,无法正常工作。当我尝试连接到localhasot:4444时,连接挂断。 日志:
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
然后没事!
我使用的净SSH 2.0.22 /红宝石1.8.7
尝试评论谷歌前进,只是做一个转发。这有帮助吗? – barrycarter 2010-06-02 17:10:57
不幸的是它不起作用。 – nakhli 2010-06-03 08:29:45