【发布时间】:2016-11-17 03:37:50
【问题描述】:
我正在尝试使用SSH.NET 创建从localhost:3306 到远程计算机上的端口3306 的隧道:
PrivateKeyFile file = new PrivateKeyFile(@" .. path to private key .. ");
using (var client = new SshClient(" .. remote server .. ", "ubuntu", file))
{
client.Connect();
var port = new ForwardedPortLocal(3306, "localhost", 3306);
client.AddForwardedPort(port);
port.Start();
// breakpoint set within the code here
client.Disconnect();
}
当断点被命中时,client.IsConnected 正在返回true,但telnet localhost 3306 没有连接。如果我使用 Putty 创建连接,并在那里设置相同的隧道,它会成功。我错过了什么?
【问题讨论】:
-
您是否收到有关 telnet 应用程序的特定警告?它关闭了吗?可能不会显示二进制连接数据...
-
挂起,连接失败。使用 Putty 时,我得到一串数据。
-
试试this link:我认为断开客户端是问题所在。如果您在
Start和Disconnect之间中断,您也可能会停止转发。 -
在旧版本的库中似乎也存在许多错误,请确保您使用的是最新版本。
-
@owlstead 谢谢 - 我已经检查过了,我使用的是 2013.4.7.0,最新版本。
标签: c# ssh portforwarding ssh.net