Currently I can use the JSch library to execute remote commands in a SSH session like this:
JSch jsch = new JSch();
Session session = jsch.getSession(username, host, 22);
session.setPassword(password);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
ChannelExec channel = (ChannelExec) session.openChannel("exec");
BufferedReader in = new BufferedReader(new InputStreamReader(channel.getInputStream()));
channel.setCommand("ls -l");
channel.connect();
StringBuilder output = new StringBuilder();
String s = null;
while((s = in.readLine()) != null){
output.append(s + "\n");
}
System.out.println(outp