Criando uma porta encaminhada dentro de um túnel SSH
Estou tentando usarSSH.NET para criar um túnel delocalhost:3306
para a porta 3306 em uma máquina remota:
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();
}
Quando o breakpoint é atingido,client.IsConnected
está retornandotrue
, mastelnet localhost 3306
não está se conectando. Se eu criar a conexão usando o Putty em vez disso, e configurar o mesmo túnel lá, ele será bem-sucedido. O que eu perdi?