我正在尝试使用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创建连接,并在那里设置相同的隧道,则可以成功。我错过了什么?