fixes and improvements

This commit is contained in:
2026-05-06 16:33:02 +02:00
parent d8d80867ce
commit 5277f21577
20 changed files with 577 additions and 222 deletions
@@ -14,6 +14,7 @@ import logging
import posixpath
import shlex
from dataclasses import dataclass
from pathlib import Path
from typing import Any
import paramiko
@@ -41,6 +42,7 @@ class RemoteSSHClient:
port: int = 22,
key_filename: str | None = None,
password: str | None = None,
known_hosts_path: str | None = None,
timeout: int = 20,
):
if not host or not username:
@@ -50,19 +52,23 @@ class RemoteSSHClient:
self.port = port
self.key_filename = key_filename or None
self.password = password or None
self.known_hosts_path = known_hosts_path or None
self.timeout = timeout
self._client: paramiko.SSHClient | None = None
def connect(self) -> paramiko.SSHClient:
"""Create or reuse the Paramiko connection.
Unknown host keys are rejected. Users should connect once manually with
ssh so the server is present in known_hosts.
Unknown host keys are rejected. The application can synthesize a managed
known_hosts file under its cache directory so users do not need to mount
their local SSH directory into the container.
"""
if self._client:
return self._client
client = paramiko.SSHClient()
client.load_system_host_keys()
if self.known_hosts_path and Path(self.known_hosts_path).is_file():
client.load_host_keys(self.known_hosts_path)
client.set_missing_host_key_policy(paramiko.RejectPolicy())
client.connect(
self.host,
@@ -119,7 +125,6 @@ class RemoteSSHClient:
was a source of file-browser confusion. Output is NUL-delimited before
Python serializes it, making spaces in filenames safe.
"""
# JSON-ish output: type, size, mtime epoch, filename. Handles spaces/newlines reasonably via NUL boundaries.
quoted = shlex.quote(path)
not_dir_message = shlex.quote(f"Not a directory: {path}")
command = (