fix(ssh): log in only with the credentials the driver is given

paramiko's look_for_keys and allow_agent stayed at their default True,
so the node login also tried every key in the running process's own
~/.ssh and any SSH agent it could reach. The driver standard lets a
driver authenticate only with what it was handed; both are now False
on every connect.

Closes #48
This commit is contained in:
Christian Manivong committed 2026-11-02 09:25:04 +01:00
1 parent b368ad9856
commit b3fe5009c8
3 files changed
+20 -1

No files matched your search

+3
View File
@@ -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
+4 -1
View File
@@ -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:
+13
View File
@@ -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