我正在使用本地到遠程端口轉發從我的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