Uses 4887K of libraries. Click here for Pure Java version (129L/2K/5K).
!752 !1000308 // sshj.jar import net.schmizz.sshj.SSHClient; import net.schmizz.sshj.common.IOUtils; import net.schmizz.sshj.connection.channel.direct.Session; static S host = "tinybrain.de"; static S user = "root"; static boolean pwAuth = true; static S command = "uptime"; p { final new SSHClient client; client.loadKnownHosts(); client.addHostKeyVerifier("5b:fd:de:ae:5b:d7:03:d2:8a:0d:0a:b6:7d:20:d0:d4"); //"tinybrain.de"; boolean pwAuth = true; client.connect(host); try { if (pwAuth) { System.out.print("User: " + user + ". Password: "); S pw = readLineHidden(); print("*"); client.authPassword(user, pw); } else { client.authPublickey(user); } final Session session = client.startSession(); print("Started session"); try { print("Executing command: " + command); final Session.Command cmd = session.exec(command); print("Output: " + IOUtils.readFully(cmd.getInputStream()).toString()); print("Joining command"); cmd.join(10, TimeUnit.SECONDS); print("Done!"); } finally { session.close(); } } finally { client.disconnect(); } }
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001229 |
Snippet name: | SSH Test (JavaX, WORKS) |
Eternal ID of this version: | #1001229/1 |
Text MD5: | f5592ff0d0ef77882c9cdb20af3059aa |
Transpilation MD5: | 0b2438087742a92154cef814488553df |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-23 13:39:52 |
Source code size: | 1215 bytes / 45 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 619 / 624 |
Referenced in: | #1003579 - quickSSH - issue SSH command on server and return output #1003580 - Test quickSSH with tinybrain.de #3000190 - Answer for stefanreich(>> t 20 questions) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |