lib.ec.ssh.Paramiko: Pass port and password

__client() connects using only the URI's hostname and username. The
URI's port is ignored, so ssh://host:2222/... ends up connecting to
port 22, and a password carried in the URI is never passed to
paramiko, so URI-based password authentication cannot work. The Exec
and AsyncSSH clients both honor the port and the password.

Pass the port and the password to connect(). The port argument is
omitted entirely when the URI carries no port, because
getaddrinfo() would interpret a None port as service port 0; without
the argument, paramiko falls back to its default of 22.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-08-16 07:01:55 +02:00
commit 4b55b460ea
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -32,10 +32,16 @@ class Paramiko(Base):
hostname = self.hostname
if hostname is None:
raise Exception('Tried to run connect without target hostname')
kwargs: dict[str, Any] = {
'hostname': hostname,
'username': self.username,
'password': self.password,
'allow_agent': True,
}
if self.port is not None:
kwargs['port'] = self.port
try:
ret.connect(
hostname = hostname, username = self.username, allow_agent = True
)
ret.connect(**kwargs)
except Exception as e:
log(ERR, f'Failed to connect to {self.hostname} ({str(e)})')
raise