• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SSH port forwarding is not working

Sachin Dimble
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to implement ssh port forwarding future in my code, i tried following steps with both Ganymed and JSCH libraries.

I have two unix boxses tunnleFrom and ExtSystem.

ExtSystem : where my stub is listning on port 10023, this stub is suppose to respond on incomning requests.
tunnleFrm : where i have run ssh -g -L11023:ExtSystem:10023 user2@tunnleFrm

Now if i fire http request http://tunnleFrm:11023 through IE my stub is responding correctly means the ssh port forwarding is working ok.

But if i send request through following code my code runs succesfully but i won't get any response from stub (am sure that request is not getting forwarded to stub).

System.out.println("port forwarding starts");
String hostname = "tunnleFrm";
String username = "user2";
String password = "user2";
Connection conn = new Connection(hostname);
boolean isAuthenticated = conn.authenticateWithPassword(username, password);

if (isAuthenticated == false)
throw new IOException("Authentication failed.");
LocalPortForwarder lpf1 = conn.createLocalPortForwarder(11023, "ExtSystem", 10023);
Session sess = conn.openSession();
System.out.println("created ssh session ");
sess.execCommand("qdn 9999999999");
System.out.println("Executed command ");

Thanks & Regards,
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15560
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you post a question on JavaRanch, please take a moment to choose the appropriate forum.

This question doesn't have anything to do with the SCJP exam, so it does not belong in the SCJP forum. I will move it to a more appropriate forum for you. Please click the link at the top of the page to continue.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic