Security Events

Detect SSH logins, SSH brute-force attempts, and port scans on each agent, then turn them into alerts.

Agents detect host-level intrusion signals and stream structured events to the server. Raw logs never leave the host — only parsed event metadata is reported. Events are browsable in the UI and can drive notifications through the standard alert pipeline.

Event Types

TypeTriggerSeverity
ssh_loginSuccessful SSH login. Marked first_seen=true when the (user, source IP) pair is newinfo (medium when first_seen=true)
ssh_brute_forceRepeated SSH failures from one source IP within a sliding windowmedium / high / critical
port_scanOne source IP hitting many distinct destination ports within a sliding windowhigh

Each event carries structured evidence (failed count, distinct users, scanned ports, etc.) and a detector_source — one of journal, auth_log, conntrack, or firewall_log. Currently, SSH events are tagged with journal even when falling back to file tailing, and kernel firewall log tailing populates blocked_count evidence.

Requirements

  • Linux only. SSH detection reads systemd journal or falls back to /var/log/auth.log or /var/log/secure; port-scan detection uses conntrack (TCP connections only).
  • CAP_SECURITY_EVENTS must be reported by the agent (bit 256, on by default). Capabilities are agent-owned — to turn it off, add security_events to the agent's [capabilities] deny list. See Capabilities.
  • For port-scan detection, install the conntrack CLI and set security.port_scan.enabled = true:
    # Debian / Ubuntu
    apt install conntrack
    # RHEL / Fedora
    dnf install conntrack-tools

Viewing Events

WherePathWhat it shows
Overview/security24h / 7d / 30d range toggle driving KPI cards (counts by type and Top Attacker IP) and timeline, filterable table (including First-seen only), and Admin one-click Block source IP
Per-serverServer detail → Security tabSame view scoped to one server
Event detailClick any rowFull evidence payload, detector source, and a VirusTotal lookup link for the source IP

New events appear in real time over WebSocket — no refresh required.

Detector Tuning

Thresholds live on the agent and apply per host. Defaults are conservative to avoid noise on busy bastions.

TOML KeyEnv VarDefaultNotes
security.enabledSERVERBEE_SECURITY__ENABLEDtrueMaster switch for all detectors
security.ssh.window_secondsSERVERBEE_SECURITY__SSH__WINDOW_SECONDS60Sliding window for SSH failure counting
security.ssh.failed_thresholdSERVERBEE_SECURITY__SSH__FAILED_THRESHOLD10Failures in the window that fire one ssh_brute_force event. Queue clears after firing
security.port_scan.enabledSERVERBEE_SECURITY__PORT_SCAN__ENABLEDfalseOff by default. Requires conntrack CLI (TCP connections only)
security.port_scan.window_secondsSERVERBEE_SECURITY__PORT_SCAN__WINDOW_SECONDS30Sliding window for distinct-port counting
security.port_scan.distinct_port_thresholdSERVERBEE_SECURITY__PORT_SCAN__DISTINCT_PORT_THRESHOLD20Distinct ports from one source IP that fire one port_scan event
security.data_dirSERVERBEE_SECURITY__DATA_DIR/var/lib/serverbee/securityPersistent first_seen store for (user, IP) pairs

Full env var reference: Configuration → Security (Agent).

sshd typically writes two failure lines per attempt (Invalid user … followed by Failed password …). With the default failed_threshold=10, expect roughly one ssh_brute_force event per 5 real failed attempts from the same IP.

Brute-Force Severity

Severity escalates with the number of distinct usernames an attacker tries inside the window — a strong signal of credential stuffing:

Distinct usernamesSeverity
1medium
2 – 4high
≥ 5critical

Evidence also reports invalid_user_count and a sample_users array (first 5 distinct names) for quick pattern spotting.

Alerting

Three event-driven rule types live under Settings → Alerts:

Rule TypeFires on
ssh_new_ip_loginssh_login events where first_seen = true
ssh_brute_force_detectedssh_brute_force events matching the configured threshold
port_scan_detectedport_scan events matching the configured threshold

Quick setup

The Alerts page surfaces three preset cards for one-click rule creation. Each preset ships with sensible defaults — pick a notification group and, optionally, the servers it applies to.

A fourth event-driven preset, Capability Temporarily Granted (capability_grant_detected), lives next to these and fires when a high-risk capability is temporarily granted on a host. It is not an intrusion signal, so it is documented separately under Alerts and Capabilities → Temporary grants.

Filters

Security rule parameters (SecurityRuleParams) apply by rule type:

  • min_failed_count (ssh_brute_force_detected) — minimum failed attempts in the event required to fire (preset default: 20).
  • min_distinct_ports (port_scan_detected) — minimum distinct scanned ports in the event required to fire (preset default: 50).
  • exclude_users (ssh_new_ip_login only) — usernames to suppress from alerts.
  • exclude_cidrs (ssh_new_ip_login only) — suppress events from trusted networks, e.g. ["10.0.0.0/8", "192.168.0.0/16"].
  • dedupe_window_seconds (all security rules) — notification deduplication window in seconds per (rule_id, server_id, source_ip) (default: 600).

Deduplication and Maintenance Windows

Notifications are deduplicated per (rule_id, server_id, event_key). The event_key includes the source IP, so:

  • Two different attackers on the same server → two notifications.
  • The same attacker re-triggering inside dedupe_window_seconds → one notification.

Security alert notifications also respect active maintenance windows and are suppressed while a server is in scheduled maintenance.

Security rule types cannot be combined with metric rules in the same alert rule, and each rule allows one security item. The validator rejects mixed or duplicated configurations — create one rule per event type.

Auto-block source IP

Brute-force and port-scan alert rules can optionally carry a block_source_ip action that auto-creates a block_list row from the triggering event's source IP. Only ssh_brute_force_detected and port_scan_detected rules accept this action — ssh_new_ip_login is intentionally forbidden because a legitimate first-time login would lock the user out.

The auto-block row uses origin = "auto" and stores the triggering origin_event_id. It is deduplicated by canonical target: if a manual or earlier auto-block already covers the triggering server, the action is silently skipped; if a row exists but does not cover the triggering server, the conflict is recorded in the audit log as firewall_auto_block_skipped_conflict and no new row is created.

See Firewall Blocklist for the full feature, guardrails, and audit-log reference.

REST API

Read endpoints are accessible to any authenticated user (Admin or Member); deleting events requires Admin.

MethodEndpointAccessDescription
GET/api/security/eventsAuthenticatedList and filter security events
GET/api/security/events/{id}AuthenticatedFetch a single security event with full evidence
GET/api/security/statsAuthenticatedAggregated KPIs, top attacker IP, and timeline
DELETE/api/security/events/{id}AdminDelete a security event

Retention

Security events are kept for 30 days by default. Tune with retention.security_event_days (env: SERVERBEE_RETENTION__SECURITY_EVENT_DAYS). The cleanup task checks for expired rows hourly.

Data Flow

sshd / kernel
     │   (journal · auth.log / secure · conntrack)
     ▼
agent detector
     │   AgentMessage::SecurityEvent  (WebSocket)
     ▼
server   ─►  security_event table
         ─►  alert evaluator  ─►  notification group
         ─►  browser broadcast (WebSocket)
                    │
                    ▼
              /security  +  Security tab