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(); } }
Began life as a copy of #1001229
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003579 |
Snippet name: | quickSSH - issue SSH command on server and return output |
Eternal ID of this version: | #1003579/1 |
Text MD5: | 95c22188fd44ae5a8a600a897629ab30 |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-09-03 14:29:21 |
Source code size: | 990 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 632 / 595 |
Referenced in: | [show references] |