From 4a946d69a59545437ba7cc39dd5ae8d20161c6eb Mon Sep 17 00:00:00 2001 From: Ryan Mukherjee Date: Tue, 20 Jun 2023 17:30:57 -0400 Subject: [PATCH 1/3] bugfix: handle ssh key login --- clearml_session/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clearml_session/__main__.py b/clearml_session/__main__.py index cc512d9..1e791fd 100644 --- a/clearml_session/__main__.py +++ b/clearml_session/__main__.py @@ -669,7 +669,7 @@ def wait_for_machine(state, task): def start_ssh_tunnel(username, remote_address, ssh_port, ssh_password, local_remote_pair_list, debug=False): print('Starting SSH tunnel') child = None - args = ['-N', '-C', + args = ['-C', '{}@{}'.format(username, remote_address), '-p', '{}'.format(ssh_port), '-o', 'UserKnownHostsFile=/dev/null', '-o', 'Compression=yes', @@ -690,7 +690,7 @@ def start_ssh_tunnel(username, remote_address, ssh_port, ssh_password, local_rem args=args, logfile=fd, timeout=20, encoding='utf-8') - i = child.expect([r'(?i)password:', r'\(yes\/no\)', r'.*[$#] ', pexpect.EOF]) + i = child.expect([r'(?i)password:', r'\(yes\/no', r'.*[$#] ', pexpect.EOF]) if i == 0: child.sendline(ssh_password) try: From 78ea4bf4f040a4738de92f8fe72929ff818cbea8 Mon Sep 17 00:00:00 2001 From: Ryan Mukherjee Date: Wed, 21 Jun 2023 11:23:40 -0400 Subject: [PATCH 2/3] revert -N, add comment --- clearml_session/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clearml_session/__main__.py b/clearml_session/__main__.py index 1e791fd..c0d396c 100644 --- a/clearml_session/__main__.py +++ b/clearml_session/__main__.py @@ -669,7 +669,7 @@ def wait_for_machine(state, task): def start_ssh_tunnel(username, remote_address, ssh_port, ssh_password, local_remote_pair_list, debug=False): print('Starting SSH tunnel') child = None - args = ['-C', + args = ['-N', '-C', '{}@{}'.format(username, remote_address), '-p', '{}'.format(ssh_port), '-o', 'UserKnownHostsFile=/dev/null', '-o', 'Compression=yes', @@ -690,6 +690,7 @@ def start_ssh_tunnel(username, remote_address, ssh_port, ssh_password, local_rem args=args, 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]) if i == 0: child.sendline(ssh_password) From 22ae1daaae960e9fb275c7f437e84dd7fa95c9e6 Mon Sep 17 00:00:00 2001 From: Ryan Mukherjee Date: Wed, 21 Jun 2023 11:32:42 -0400 Subject: [PATCH 3/3] remove `-N` --- clearml_session/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearml_session/__main__.py b/clearml_session/__main__.py index c0d396c..6e1e242 100644 --- a/clearml_session/__main__.py +++ b/clearml_session/__main__.py @@ -669,7 +669,7 @@ def wait_for_machine(state, task): def start_ssh_tunnel(username, remote_address, ssh_port, ssh_password, local_remote_pair_list, debug=False): print('Starting SSH tunnel') child = None - args = ['-N', '-C', + args = ['-C', '{}@{}'.format(username, remote_address), '-p', '{}'.format(ssh_port), '-o', 'UserKnownHostsFile=/dev/null', '-o', 'Compression=yes',