java - I am tring to jump to another host using JSch, but it is not working -


i use jsch connect server , works send command using exec , shell channel, want connect server through first connection, application crashes when trying connect second session, not sure if set code correctly or not

public session connect() throws jschexception{  string host1 = "192.168.1.1"; string host2 = "192.168.2.2"; string username = "host"; string password = "pass";     jsch jsch = new jsch(); session s; s = jsch.getsession(username, host1, 22); properties config = new properties(); config.put("stricthostkeychecking", "no"); s.setconfig(config); s.setpassword(password); s.connect(); s.setportforwardingl(22, host2, 22); session secondsession = jsch.getsession(username, host2, 22); config.put("stricthostkeychecking", "no"); secondsession.setconfig(config); secondsession.setpassword(password); secondsession.connect();  return secondsession;  } 

after declare , assign secondsession, didn't mean setconfig , setpassword on secondsession, instead of on s again?

secondsession.setconfig(config); secondsession.setpassword(password); secondsession.connect(); 

Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -