Open lukamicoder opened 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
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
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