lib 1000308 // sshj.jar import net.schmizz.sshj.SSHClient; import net.schmizz.sshj.common.IOUtils; import net.schmizz.sshj.connection.channel.direct.Session; // not sure which encoding is used for input and output // pass == null => try our public key static S quickSSH(S host, S verifier, S pass, S command, int timeoutSeconds) ctex { final new SSHClient client; client.loadKnownHosts(); client.connect(host); try { if (pass == null) client.authPublickey(user); else client.authPassword(user, pass); final Session session = client.startSession(); //print("Started session"); try { //print("Executing command: " + command); final Session.Command cmd = session.exec(command); S output = IOUtils.readFully(cmd.getInputStream()).toString(); cmd.join(timeoutSeconds, TimeUnit.SECONDS); ret output; } finally { session.close(); } } finally { client.disconnect(); } }