From a65e8eed6a92eecf57668f8c4910a7f8d4868ae5 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:54:14 -0800 Subject: [PATCH] Auto-update: Wed Nov 13 15:54:14 PST 2024 --- .DS_Store | Bin 0 -> 6148 bytes sijapi.15s.py | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .DS_Store mode change 100644 => 100755 sijapi.15s.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c349505eeed85efb58f23cf07f0f726e7122b228 GIT binary patch literal 6148 zcmeHKJ5Iw;5Znb9meQo8d?!H44NPQeid1wc1O=o-ju7-dPPK+&zptFTtsTPp}g2KHOre%>?9)J26e@*k#7?FK&K<_bRd5OOcxpz_zeX< E0k^{`t^fc4 literal 0 HcmV?d00001 diff --git a/sijapi.15s.py b/sijapi.15s.py old mode 100644 new mode 100755 index 3103726..7856e8f --- a/sijapi.15s.py +++ b/sijapi.15s.py @@ -45,7 +45,26 @@ def run_ssh_command(server, command): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: - ssh.connect(server['ts_ip'], port=server['ssh_port'], username=server['ssh_user'], password=server['ssh_pass']) + # Determine authentication method + if 'ssh_key' in server: + # Use SSH key authentication + ssh.connect( + server['ts_ip'], + port=server['ssh_port'], + username=server['ssh_user'], + key_filename=server['ssh_key'] + ) + elif 'ssh_pass' in server: + # Use password authentication + ssh.connect( + server['ts_ip'], + port=server['ssh_port'], + username=server['ssh_user'], + password=server['ssh_pass'] + ) + else: + raise ValueError("Neither ssh_key nor ssh_pass provided in server configuration") + stdin, stdout, stderr = ssh.exec_command(command) result = stdout.read().decode().strip() error = stderr.read().decode().strip() @@ -58,6 +77,7 @@ def run_ssh_command(server, command): finally: ssh.close() + def check_health(ip, port): try: response = requests.get(f"http://{ip}:{port}/health", timeout=5, verify=False)