From 951398bdb364187a00494677a1610d440438f164 Mon Sep 17 00:00:00 2001 From: Philipp Kolberg Date: Thu, 23 Jan 2025 10:08:25 +0100 Subject: [PATCH] Enhance SSH tunnel error handling to include permission denied case --- clearml_session/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clearml_session/__main__.py b/clearml_session/__main__.py index 330d3f2..b6fd210 100644 --- a/clearml_session/__main__.py +++ b/clearml_session/__main__.py @@ -937,7 +937,7 @@ def start_ssh_tunnel(username, remote_address, ssh_port, ssh_password, local_rem logfile=fd, timeout=20, encoding='utf-8') # Match only "(yes/no" in order to handle both (yes/no) and (yes/no/[fingerprint]) - i = child.expect([r'(?i)password:', r'\(yes\/no', r'.*[$#] ', pexpect.EOF]) + i = child.expect([r'(?i)password:', r'\(yes\/no', r'.*[$#] ', r'Permission denied \(publickey,password\)', pexpect.EOF]) if i == 0: child.sendline(ssh_password) try: @@ -974,6 +974,8 @@ def start_ssh_tunnel(username, remote_address, ssh_port, ssh_password, local_rem raise ValueError('Incorrect password') except pexpect.TIMEOUT: pass + elif i == 3: + raise Exception("SSH tunneling failed: please enable password authentication in your SSH client config.") except Exception as ex: if debug: print("ERROR: running local SSH client [{}] failed connecting to {}: {}".format(command, args, ex))