I did that but I got "connection refused"
StringBuilder outputBuffer = new StringBuilder(); String host="10.0.0.1"; // First level target String user="user1"; String password="pass1"; String tunnelRemoteHost="10.0.0.22"; // The host of the second target String secondPassword="pass2"; int port=22; JSch jsch=new JSch(); Session session=jsch.getSession(user, host, port); session.setPassword(password); localUserInfo lui=new localUserInfo(); session.setUserInfo(lui); session.setConfig("StrictHostKeyChecking", "no"); // create port from 2233 on local system to port 22 on tunnelRemoteHost session.setPortForwardingL(2251, tunnelRemoteHost, 22); session.connect(); session.openChannel("direct-tcpip"); // create a session connected to port 2233 on the local host. Session secondSession = jsch.getSession("user2", tunnelRemoteHost, 2251); secondSession.setPassword(secondPassword); secondSession.setUserInfo(lui); secondSession.setConfig("StrictHostKeyChecking", "no"); secondSession.connect(); // now we're connected to the secondary system Channel channel=secondSession.openChannel("exec"); ((ChannelExec)channel).setCommand("hostname"); channel.setInputStream(null); InputStream stdout=channel.getInputStream(); channel.connect(); ------------------------------------------------------------------------------ _______________________________________________ JSch-users mailing list JSch-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jsch-users