Support not specifying an SSH key in local node provider (#9864)

This commit is contained in:
Ameer Haj Ali
2020-08-04 10:23:43 -05:00
committed by GitHub
parent 3f1e3bc354
commit 6c9ec10540
3 changed files with 13 additions and 7 deletions
+9 -4
View File
@@ -239,7 +239,8 @@ class SSHOptions:
def to_ssh_options_list(self, *, timeout=60):
self.arg_dict["ConnectTimeout"] = "{}s".format(timeout)
return ["-i", self.ssh_key] + [
ssh_key_option = ["-i", self.ssh_key] if self.ssh_key else []
return ssh_key_option + [
x for y in (["-o", "{}={}".format(k, v)]
for k, v in self.arg_dict.items()
if v is not None) for x in y
@@ -261,7 +262,7 @@ class SSHCommandRunner(CommandRunnerInterface):
self.node_id = node_id
self.use_internal_ip = use_internal_ip
self.provider = provider
self.ssh_private_key = auth_config["ssh_private_key"]
self.ssh_private_key = auth_config.get("ssh_private_key")
self.ssh_user = auth_config["ssh_user"]
self.ssh_control_path = ssh_control_path
self.ssh_ip = None
@@ -433,8 +434,12 @@ class SSHCommandRunner(CommandRunnerInterface):
self.process_runner.check_call(command)
def remote_shell_command_str(self):
return "ssh -o IdentitiesOnly=yes -i {} {}@{}\n".format(
self.ssh_private_key, self.ssh_user, self.ssh_ip)
if self.ssh_private_key:
return "ssh -o IdentitiesOnly=yes -i {} {}@{}\n".format(
self.ssh_private_key, self.ssh_user, self.ssh_ip)
else:
return "ssh -o IdentitiesOnly=yes {}@{}\n".format(
self.ssh_user, self.ssh_ip)
class DockerCommandRunner(SSHCommandRunner):