mirror of
https://github.com/wassname/ray.git
synced 2026-07-02 09:38:00 +08:00
Support not specifying an SSH key in local node provider (#9864)
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -558,7 +558,7 @@ def get_or_create_head_node(config, config_file, no_restart, restart_only, yes,
|
||||
# head node won't be able to connect to workers
|
||||
remote_config["auth"].pop("ssh_proxy_command", None)
|
||||
|
||||
if config["provider"]["type"] != "kubernetes":
|
||||
if "ssh_private_key" in config["auth"]:
|
||||
remote_key_path = "~/ray_bootstrap_key.pem"
|
||||
remote_config["auth"]["ssh_private_key"] = remote_key_path
|
||||
|
||||
@@ -578,7 +578,7 @@ def get_or_create_head_node(config, config_file, no_restart, restart_only, yes,
|
||||
"~/ray_bootstrap_config.yaml": remote_config_file.name
|
||||
})
|
||||
|
||||
if config["provider"]["type"] != "kubernetes":
|
||||
if "ssh_private_key" in config["auth"]:
|
||||
config["file_mounts"].update({
|
||||
remote_key_path: config["auth"]["ssh_private_key"],
|
||||
})
|
||||
|
||||
@@ -46,7 +46,8 @@ provider:
|
||||
# How Ray will authenticate with newly launched nodes.
|
||||
auth:
|
||||
ssh_user: YOUR_USERNAME
|
||||
ssh_private_key: ~/.ssh/id_rsa
|
||||
# Optional if an ssh private key is necessary to ssh to the cluster.
|
||||
# ssh_private_key: ~/.ssh/id_rsa
|
||||
|
||||
# Leave this empty.
|
||||
head_node: {}
|
||||
|
||||
Reference in New Issue
Block a user