Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Port forwarding does not work #44

Open
lukamicoder opened this issue Oct 31, 2012 · 2 comments
Open

Port forwarding does not work #44

lukamicoder opened this issue Oct 31, 2012 · 2 comments

Comments

@lukamicoder
Copy link

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
Copy link

darth10 commented Nov 1, 2012

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
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants