Hi,

   +-From: Paul Ebermann <paul-eberm...@gmx.de> --
   |_Date: Thu, 28 Apr 2011 03:04:12 +0200 __
   |
   |I am outside this network, but I have an IP address of one of those gateway 
nodes. To
   |access any of the non-gateway nodes, our program until now opened an JSch 
Session
   |(gateway) to the gateway node, and then used
   |
   |  gateway.setPortForwardingL(localPort, ipNode, 22);
   |
   |with a random local port. Then it opened a new Session:
   |
   |  jsch.getSession(username, "127.0.0.1", localPort);
   |
   |This worked fine (but seemed to neccesiate 
setConfig("StrictHostKeyChecking", "no"),
   | since all connections now did go to 127.0.0.1).

The following will be better in that scenario,

  int localPort = gateway.setPortForwardingL(0, ipNode, 22);
  Session session = jsch.getSession(username, "127.0.0.1", localPort);
  session.setHostKeyAlias(ipNode);
  ...

And then, the following change my do the trick,

               public void connect(SocketFactory ignore, String host,
                                  int port, int timeout)
                               throws Exception {
                       activator.logInfo("setup tunnel through gateway to " +
                                          host +":"+port + "...");
                       channel = 
(ChannelDirectTCPIP)gateway.openChannel("direct-tcpip");
                       channel.setHost(host);
                       channel.setPort(port);
                       iStream = channel.getInputStream();     // !!
                       oStream = channel.getOutputStream();    // !!
                       channel.connect();
                       // iStream = channel.getInputStream();
                       // oStream = channel.getOutputStream();
                       activator.logInfo("tunnel to "+host +":"+port + " 
established.");
               }


Sincerely,
--
Atsuhiko Yamanaka
JCraft,Inc.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Tel +81-22-723-2150
    +1-415-578-3454
Skype callto://jcraft/
Twitter: http://twitter.com/ymnk

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to