Tag: portforwarding ssh.net

在SSH隧道中创建转发端口

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