diff --git a/pkgs/clan-cli/clan_cli/ssh/host.py b/pkgs/clan-cli/clan_cli/ssh/host.py index e1b8df550..56a4fca44 100644 --- a/pkgs/clan-cli/clan_cli/ssh/host.py +++ b/pkgs/clan-cli/clan_cli/ssh/host.py @@ -38,13 +38,15 @@ class Host: def __post_init__(self) -> None: if not self.command_prefix: self.command_prefix = self.host + if not self.user: + self.user = "root" def __str__(self) -> str: return self.target @property def target(self) -> str: - return f"{self.user or 'root'}@{self.host}" + return f"{self.user}@{self.host}" @classmethod def from_host(cls, host: "Host") -> "Host": diff --git a/pkgs/clan-cli/clan_cli/tests/test_ssh_remote.py b/pkgs/clan-cli/clan_cli/tests/test_ssh_remote.py index 18d9b4c20..e141d4b09 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_ssh_remote.py +++ b/pkgs/clan-cli/clan_cli/tests/test_ssh_remote.py @@ -114,7 +114,9 @@ def test_parse_deployment_address( assert result.host == expected_host assert result.port == expected_port - assert result.user == expected_user + assert result.user == expected_user or ( + expected_user == "" and result.user == "root" + ) assert result.ssh_options == expected_options