Uses 4887K of libraries. Click here for Pure Java version (129L/2K/5K).
1 | !752 |
2 | !1000308 // sshj.jar |
3 | |
4 | import net.schmizz.sshj.SSHClient; |
5 | import net.schmizz.sshj.common.IOUtils; |
6 | import net.schmizz.sshj.connection.channel.direct.Session; |
7 | |
8 | static S host = "tinybrain.de"; |
9 | static S user = "root"; |
10 | static boolean pwAuth = true; |
11 | static S command = "uptime"; |
12 | |
13 | p { |
14 | final new SSHClient client; |
15 | client.loadKnownHosts(); |
16 | client.addHostKeyVerifier("5b:fd:de:ae:5b:d7:03:d2:8a:0d:0a:b6:7d:20:d0:d4"); |
17 | //"tinybrain.de"; |
18 | boolean pwAuth = true; |
19 | client.connect(host); |
20 | try { |
21 | if (pwAuth) { |
22 | System.out.print("User: " + user + ". Password: "); |
23 | S pw = readLineHidden(); |
24 | print("*"); |
25 | client.authPassword(user, pw); |
26 | } else { |
27 | client.authPublickey(user); |
28 | } |
29 | |
30 | final Session session = client.startSession(); |
31 | print("Started session"); |
32 | try { |
33 | print("Executing command: " + command); |
34 | final Session.Command cmd = session.exec(command); |
35 | print("Output: " + IOUtils.readFully(cmd.getInputStream()).toString()); |
36 | print("Joining command"); |
37 | cmd.join(10, TimeUnit.SECONDS); |
38 | print("Done!"); |
39 | } finally { |
40 | session.close(); |
41 | } |
42 | } finally { |
43 | client.disconnect(); |
44 | } |
45 | } |
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: | 618 / 624 |
Referenced in: | [show references] |