diff --git a/CHANGELOG.md b/CHANGELOG.md index d0976c6..0c64e66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -129,6 +129,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Only what a command prints on stdout is its output; stderr no longer stands in when stdout is empty. Each command goes straight to SSH: the driver first posted it to `/nodes/{node}/execute`, which runs API calls, not a shell, and always failed (#17). +- The SSH login to the node uses only the credentials it is given + (`ssh_private_key_str`, `ssh_password` or the API password): paramiko no longer also + tries the keys in the running process's `~/.ssh` or an SSH agent it can reach (#48). ## [0.8.0] - 2026-10-23 diff --git a/napalm_proxmox/driver.py b/napalm_proxmox/driver.py index 5a1c40a..bab68ea 100644 --- a/napalm_proxmox/driver.py +++ b/napalm_proxmox/driver.py @@ -337,10 +337,13 @@ class ProxmoxDriver( import paramiko if self._ssh_client is None: - # A key is tried first; paramiko falls back to the password. + # A key is tried first; paramiko falls back to the password. Only + # these: not the keys in the process's own ~/.ssh, nor an agent. connect_kwargs: _JsonDict = { "username": self._ssh_username or self.username, "timeout": self.timeout, + "look_for_keys": False, + "allow_agent": False, } password = self._ssh_password or self.password if password: diff --git a/tests/test_ssh_login_key.py b/tests/test_ssh_login_key.py index d9397d4..207edcc 100644 --- a/tests/test_ssh_login_key.py +++ b/tests/test_ssh_login_key.py @@ -77,3 +77,16 @@ def test_a_token_only_login_sends_no_empty_password(client): # noqa: F811 )._node_ssh() assert "password" not in client.connected_with + + +@pytest.mark.parametrize( + "args", + [{"ssh_private_key_str": _ed25519_pem()}, {"ssh_password": "ssh-pw"}, {}], + ids=["key", "ssh-password", "api-password"], +) +def test_only_the_given_credentials_log_in(client, args): # noqa: F811 + """Neither the keys in the worker's own ~/.ssh nor an SSH agent it reaches (#48).""" + ProxmoxDriver("10.0.0.9", "root", "api-s3cret", optional_args=args)._node_ssh() + + assert client.connected_with["look_for_keys"] is False + assert client.connected_with["allow_agent"] is False