I am trying to connect in Java to my machines in the cloud using JSCH.

My machine's IP is 10.0.0.1.

In this host machine I want to connect to a nested machine with IP 10.0.0.22.

Actually I am connecting to the 10.0.0.1 machine using the following code:

private static String user = "ubuntu";
  private static  String host = "10.0.0.1";
  private static  String password = "mypass";
  private static  String command = "ls";

  public static void main(String args[]) throws JSchException,
InterruptedException
  {
    JSch jsch = new JSch();
    Session session = jsch.getSession(user, host, 22);
    session.setPassword(password);
    session.setConfig("StrictHostKeyChecking", "no");
    session.connect(10*1000);
    Channel channel = session.openChannel("shell");
    InputStream is = new ByteArrayInputStream(command.getBytes());
    channel.setInputStream(is);
    channel.setOutputStream(System.out);
    channel.connect(15 * 1000);
    Thread.sleep(3*1000);


    channel.disconnect();
    session.disconnect();
  }

My question is how could I open a new connection to the machine
10.0.0.22 inside the 10.0.0.1's machine using JSCH API?

------------------------------------------------------------------------------
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to