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
| Type | Trigger | Severity |
|---|---|---|
ssh_login | Successful SSH login. Marked first_seen=true when the (user, source IP) pair is new | info (medium when first_seen=true) |
ssh_brute_force | Repeated SSH failures from one source IP within a sliding window | medium / high / critical |
port_scan | One source IP hitting many distinct destination ports within a sliding window | high |
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.logor/var/log/secure; port-scan detection usesconntrack(TCP connections only). CAP_SECURITY_EVENTSmust be reported by the agent (bit256, on by default). Capabilities are agent-owned — to turn it off, addsecurity_eventsto the agent's[capabilities]deny list. See Capabilities.- For port-scan detection, install the
conntrackCLI and setsecurity.port_scan.enabled = true:# Debian / Ubuntu apt install conntrack # RHEL / Fedora dnf install conntrack-tools
Viewing Events
| Where | Path | What it shows |
|---|---|---|
| Overview | /security | 24h / 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-server | Server detail → Security tab | Same view scoped to one server |
| Event detail | Click any row | Full 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 Key | Env Var | Default | Notes |
|---|---|---|---|
security.enabled | SERVERBEE_SECURITY__ENABLED | true | Master switch for all detectors |
security.ssh.window_seconds | SERVERBEE_SECURITY__SSH__WINDOW_SECONDS | 60 | Sliding window for SSH failure counting |
security.ssh.failed_threshold | SERVERBEE_SECURITY__SSH__FAILED_THRESHOLD | 10 | Failures in the window that fire one ssh_brute_force event. Queue clears after firing |
security.port_scan.enabled | SERVERBEE_SECURITY__PORT_SCAN__ENABLED | false | Off by default. Requires conntrack CLI (TCP connections only) |
security.port_scan.window_seconds | SERVERBEE_SECURITY__PORT_SCAN__WINDOW_SECONDS | 30 | Sliding window for distinct-port counting |
security.port_scan.distinct_port_threshold | SERVERBEE_SECURITY__PORT_SCAN__DISTINCT_PORT_THRESHOLD | 20 | Distinct ports from one source IP that fire one port_scan event |
security.data_dir | SERVERBEE_SECURITY__DATA_DIR | /var/lib/serverbee/security | Persistent 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 usernames | Severity |
|---|---|
| 1 | medium |
| 2 – 4 | high |
| ≥ 5 | critical |
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 Type | Fires on |
|---|---|
ssh_new_ip_login | ssh_login events where first_seen = true |
ssh_brute_force_detected | ssh_brute_force events matching the configured threshold |
port_scan_detected | port_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_loginonly) — usernames to suppress from alerts.exclude_cidrs(ssh_new_ip_loginonly) — 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.
| Method | Endpoint | Access | Description |
|---|---|---|---|
| GET | /api/security/events | Authenticated | List and filter security events |
| GET | /api/security/events/{id} | Authenticated | Fetch a single security event with full evidence |
| GET | /api/security/stats | Authenticated | Aggregated KPIs, top attacker IP, and timeline |
| DELETE | /api/security/events/{id} | Admin | Delete 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