1 | !include once #1036018 // SSH + SCP Libs |
2 | |
3 | sbool sshLogin_keepOpen; |
4 | sS sshLogin_openUser; |
5 | sS sshLogin_openHost; |
6 | static SSHClient sshLogin_client; |
7 | static Lock sshLogin_lock = lock(); |
8 | |
9 | // quickest version - allow any host ID and search for pw in JavaX-Secret |
10 | static SSHClient sshLogin(S user, S host) ctex { |
11 | { |
12 | lock sshLogin_lock; |
13 | if (sshLogin_client != null && eq(sshLogin_openUser, user) |
14 | && eq(sshLogin_openHost, host)) |
15 | ret sshLogin_client; |
16 | } |
17 | S pass = findSSHPassword(user, host); |
18 | final new SSHClient client; |
19 | client.addHostKeyVerifier(new PromiscuousVerifier); |
20 | client.connect(host); |
21 | try { |
22 | client.authPassword(user, pass); |
23 | } catch e { |
24 | client.disconnect(); |
25 | rethrow(e); |
26 | } |
27 | lock sshLogin_lock; |
28 | if (sshLogin_keepOpen && sshLogin_client == null) { |
29 | sshLogin_openUser = user; |
30 | sshLogin_openHost = host; |
31 | sshLogin_client = client; |
32 | } |
33 | ret client; |
34 | } |
35 | |
36 | svoid cleanMeUp_sshLogin { |
37 | lock sshLogin_lock; |
38 | if (sshLogin_client != null) { |
39 | pcall { sshLogin_client.disconnect(); } |
40 | sshLogin_client = null; |
41 | } |
42 | } |
Began life as a copy of #1004835
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009980 |
Snippet name: | sshLogin |
Eternal ID of this version: | #1009980/10 |
Text MD5: | f4536eb4928b912b7a0c3f362e74b25a |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-31 20:19:32 |
Source code size: | 1104 bytes / 42 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 518 / 583 |
Version history: | 9 change(s) |
Referenced in: | [show references] |