diff --git a/crmsh/bootstrap.py b/crmsh/bootstrap.py index 145ce8044e..9bf1c9ba24 100644 --- a/crmsh/bootstrap.py +++ b/crmsh/bootstrap.py @@ -1789,7 +1789,14 @@ def join_ssh_with_ssh_agent( ): # As ssh-agent is used, the local_user does not have any effects shell = sh.SSHShell(local_shell, 'root') - # FIXME: detect the availability of ssh session + if not shell.can_run_as(seed_host, seed_user): + raise ValueError(f'Failed to login to {seed_user}@{seed_host}') + if seed_user != 'root' and 0 != shell.subprocess_run_without_input( + seed_host, seed_user, 'sudo true', + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ).returncode: + raise ValueError(f'Failed to sudo on {seed_user}@{seed_host}') authorized_key_manager = ssh_key.AuthorizedKeyManager(shell) for key in ssh_public_keys: authorized_key_manager.add(None, local_user, key)