I'm attempting to use SSH.NET to create a tunnel from localhost:3306
to port 3306 on a remote machine:
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();
}
When the breakpoint is hit, client.IsConnected
is returning true
, but telnet localhost 3306
is not connecting. If I create the connection using Putty instead, and set up the same tunnel there, it succeeds. What have I missed?