connect fix 4

This commit is contained in:
2026-08-21 06:14:10 +02:00
parent bf2a02679d
commit 5e506c9921
17 changed files with 1266 additions and 162 deletions

View File

@ -24,9 +24,11 @@ from app.recordings.recorder import SessionRecorder
from app.security import active_sessions
from app.security.audit import write_audit_event
from app.ssh_proxy.proxy import (
SSH_SETUP_ERRORS,
HostNotConfiguredError,
PrivateKeyUnusableError,
connect_to_host,
describe_connection_error,
load_host,
)
@ -153,11 +155,18 @@ async def ssh_terminal(websocket: WebSocket, host_id: int):
await websocket.send_json({"type": "error", "message": str(exc)})
except Exception:
logger.debug("Fehlermeldung konnte nicht mehr an Client gesendet werden", exc_info=True)
except HostNotConfiguredError as exc:
except SSH_SETUP_ERRORS as exc:
# Alles, was den Sitzungsaufbau verhindert und der Benutzer selbst
# einordnen kann: fehlender Benutzername/Schluessel, nicht gepinnter
# oder abweichender Host-Key, unerreichbares Ziel. Bewusst mit
# Klartextmeldung statt "interner Fehler" -- der Grund steht in der
# Konfiguration, nicht im Code.
logger.warning("SSH-Sitzung %s abgebrochen: %s", session_id, exc)
end_reason = "error"
try:
await websocket.send_json({"type": "error", "message": str(exc)})
await websocket.send_json(
{"type": "error", "message": describe_connection_error(exc)}
)
except Exception:
logger.debug("Fehlermeldung konnte nicht mehr an Client gesendet werden", exc_info=True)
except asyncio.CancelledError: