fixes and improvements

This commit is contained in:
2026-05-07 20:36:37 +02:00
parent 420dc34272
commit c73cfa27c3
4 changed files with 51 additions and 22 deletions
@@ -13,7 +13,7 @@ from media_library_viewer_api.clients.ssh import RemoteSSHClient
from media_library_viewer_api.config import get_settings
from media_library_viewer_api.dependencies import get_monitoring_poller, get_settings_store
from media_library_viewer_api.services.db_maintenance import remove_sqlite_database
from media_library_viewer_api.services.known_hosts import ensure_known_host
from media_library_viewer_api.services.known_hosts import has_known_host
from media_library_viewer_api.services.media_index import MediaIndex
from media_library_viewer_api.services.settings_store import SettingsStore
@@ -98,20 +98,7 @@ def test_machine_ssh(
client, host, port = _resolve_ssh_client(machine, store)
settings = get_settings()
try:
known_hosts_updated = ensure_known_host(host, port, settings.ssh_known_hosts_file, strict=True)
except RuntimeError as exc:
message = str(exc)
lowered = message.lower()
if "protocol banner" in lowered:
raise HTTPException(
status_code=status.HTTP_502_BAD_GATEWAY,
detail=(
f"SSH banner not received from {host}:{port}; the backend could not record the host key. "
"Confirm the SSH service, host, and port are reachable."
),
) from exc
raise HTTPException(status_code=status.HTTP_502_BAD_GATEWAY, detail=message) from exc
known_hosts_updated = not has_known_host(host, port, settings.ssh_known_hosts_file)
try:
client.connect()