You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Server collector opens ~20 SSH connections per incident: reuse one connection or batch the checks #212
ServerCollector.collect() opens a new SSH connection for every command: OS detection plus 18–21 checks means about 20 separate SSH handshakes per incident, each with a 15s timeout. On a remote host:
collection takes 10–30s instead of 1–2s, and up to 5 minutes when the host is struggling, which is exactly when the agent is called,
every connection writes an auth-log entry and runs PAM/MOTD scripts; hosts using fail2ban/sshguard or per-user connection limits (MaxStartups) can rate-limit or ban the agent,
the agent's own SSH sessions flood the auth logs the threat detector reads.
Proposed fix
Reuse one connection with OpenSSH multiplexing in tools/ssh_utils.build_ssh_argv: -o ControlMaster=auto -o ControlPath=<private dir>/%C -o ControlPersist=60. Keep the 0700 directory per process, and keep host-key checking unchanged (see the existing tests in tests/test_ssh_remote.py).
Or send all read-only checks as one script over a single SSH session and split the output by markers. This is better for Windows, where there's no ControlMaster.
Make the per-command timeout and an overall collection budget configurable (SERVER_COLLECT_TIMEOUT_SEC).
Tests: the argv includes the control options; a batched script parses back into the same keys; the existing SSH hardening tests still pass.
Activity