From eded9429b9b3efeba5e78c3d8f8b430d97e32c62 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 9 Aug 2024 15:14:59 -0400 Subject: [PATCH] xxx: try to use test user name from config Signed-off-by: John Mulligan --- teuthology/misc.py | 3 ++- teuthology/task/ssh_keys.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 97521895ac..06cb14f213 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -51,7 +51,8 @@ def host_shortname(hostname): else: return hostname.split('.', 1)[0] -def canonicalize_hostname(hostname, user: Optional[str] ='ubuntu'): +def canonicalize_hostname(hostname, user: Optional[str] = None): + user = user or get_test_user() hostname_expr = hostname_expr_templ.format( lab_domain=config.lab_domain.replace('.', r'\.')) match = re.match(hostname_expr, hostname) diff --git a/teuthology/task/ssh_keys.py b/teuthology/task/ssh_keys.py index 0f497ebe90..a6d57c5f59 100644 --- a/teuthology/task/ssh_keys.py +++ b/teuthology/task/ssh_keys.py @@ -93,21 +93,22 @@ def tweak_ssh_config(ctx, config): """ Turn off StrictHostKeyChecking """ + user = misc.get_test_user() run.wait( ctx.cluster.run( args=[ 'echo', 'StrictHostKeyChecking no\n', run.Raw('>'), - run.Raw('/home/ubuntu/.ssh/config'), + run.Raw(f'/home/{user}/.ssh/config'), run.Raw('&&'), 'echo', 'UserKnownHostsFile ', run.Raw('/dev/null'), run.Raw('>>'), - run.Raw('/home/ubuntu/.ssh/config'), + run.Raw(f'/home/{user}/.ssh/config'), run.Raw('&&'), - run.Raw('chmod 600 /home/ubuntu/.ssh/config'), + run.Raw(f'chmod 600 /home/{user}/.ssh/config'), ], wait=False, ) @@ -119,7 +120,7 @@ def tweak_ssh_config(ctx, config): finally: run.wait( ctx.cluster.run( - args=['rm',run.Raw('/home/ubuntu/.ssh/config')], + args=['rm',run.Raw(f'/home/{user}/.ssh/config')], wait=False ), ) -- 2.39.5