!include once #1036018 // SSH + SCP Libs sbool sshLogin_keepOpen; sS sshLogin_openUser; sS sshLogin_openHost; static SSHClient sshLogin_client; static Lock sshLogin_lock = lock(); // quickest version - allow any host ID and search for pw in JavaX-Secret static SSHClient sshLogin(S user, S host) ctex { { lock sshLogin_lock; if (sshLogin_client != null && eq(sshLogin_openUser, user) && eq(sshLogin_openHost, host)) ret sshLogin_client; } S pass = findSSHPassword(user, host); final new SSHClient client; client.addHostKeyVerifier(new PromiscuousVerifier); client.connect(host); try { client.authPassword(user, pass); } catch e { client.disconnect(); rethrow(e); } lock sshLogin_lock; if (sshLogin_keepOpen && sshLogin_client == null) { sshLogin_openUser = user; sshLogin_openHost = host; sshLogin_client = client; } ret client; } svoid cleanMeUp_sshLogin { lock sshLogin_lock; if (sshLogin_client != null) { pcall { sshLogin_client.disconnect(); } sshLogin_client = null; } }
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: | 517 / 582 |
Version history: | 9 change(s) |
Referenced in: | [show references] |