I am trying to build in SSH port forwarding into a .NET application that I am writing.
I have tried using sharpSSH, but it requires the user to input their password
The SSH.NET library is a simple way to achieve this:
using (var client = new SshClient("client.net", "user", "password"))
{
client.Connect();
var port = new ForwardedPortLocal("localhost", 10000, "remote.net", 80);
client.AddForwardedPort(port);
port.Exception += delegate(object sender, ExceptionEventArgs e)
{
Console.WriteLine(e.Exception.ToString());
};
port.Start();
// ... hold the port open ... //
port.Stop();
client.Disconnect();
}