mono / ngit

Automated jgit port to c#
261 stars 152 forks source link

Port forwarding does not work #44

Open lukamicoder opened 11 years ago

lukamicoder commented 11 years ago

I created a console app with NSch.dll and the required Sharpen and Mono dlls. It can connect to the SSH server (from Windows 7 to Debian), but cannot forward remote port 10080 to my local machine's port 8080. However, reverse tunneling does work: it can forward my local port 10080 to remote port 8080.

var session = jsch.GetSession("root", "192.168.1.136", 22); session.SetPassword("password"); session.SetConfig("StrictHostKeyChecking", "no"); session.Connect();

//works. I get back the server version. Console.WriteLine("SSH Server: " + session.GetServerVersion());

int assignedPort = session.SetPortForwardingL(8080, "192.168.1.136", 10080); //does not work, although I properly get back the assigned port. Console.WriteLine("Assigned Port: " + assignedPort);

//works fine. session.SetPortForwardingR(8080, "localhost", 10080);

Is this a bug or I am doing something wrong?

Karl

darth10 commented 11 years ago

Looks like setPortForwardingL is for local-side port forwarding. Check the [API docs](http://epaul.github.com/jsch-documentation/javadoc/com/jcraft/jsch/Session.html#setPortForwardingL(java.lang.String, int, java.lang.String, int, com.jcraft.jsch.ServerSocketFactory).

However, if that's the intention, then this looks like a bug in NSch.

Edit: link

lukamicoder commented 11 years ago

Thanks for your reply.

I didn't realize I have to provide the local address as well. Unfortunately, this code still doesn't work:

int assignedPort = session.SetPortForwardingL("127.0.0.1", 8080, "192.168.1.136", 10080);

So it does seem to be a bug.

Karl