Windows ボックスからローカルからリモートへのポート転送を使用して、リモート データベースにアクセスしています。ポート転送にパテを使用すると魅力的に機能しますが、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 へのポート転送は正常に機能します。db サーバーがポート 1234 でリッスンしている Linux サーバーへのポート転送が機能していません。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
そして、何も!
私はnet-ssh 2.0.22 / ruby 1.8.7を使用しています