diff --git a/docs/home-server/mercury.md b/docs/home-server/mercury.md index c2d6c8c..333f6a9 100644 --- a/docs/home-server/mercury.md +++ b/docs/home-server/mercury.md @@ -18,6 +18,16 @@ sources: reference: "Mercury Uptime Kuma only checks WireGuard tunnel health and whether Jupiter is online; alerts Jay on Discord when down, 2026-10-26" - kind: owner-report reference: "Mercury monitored in Beszel; CPU above 90% for 10 minutes, memory above 90% for 10 minutes and any failed systemd services alerts configured, 2026-10-26" + - kind: owner-report + reference: "fail2ban-client version and status output: Fail2ban 1.1.0 with three active jails (nginx-botsearch, nginx-http-auth, sshd), 2026-10-26" + - kind: owner-report + reference: "fail2ban-client get output for each jail: maxretry, findtime, bantime and ignoreip, 2026-10-26" + - kind: owner-report + reference: "fail2ban-client logpath, journalmatch and actions output: sshd uses journal match _SYSTEMD_UNIT=ssh.service + _COMM=sshd; nginx jails use error.log/access.log; all three use nftables action, 2026-10-26" + - kind: owner-report + reference: "Non-comment jail overrides supplied from /etc/fail2ban/jail.local and /etc/fail2ban/jail.d/defaults-debian.conf, 2026-10-26" + - kind: owner-report + reference: "Fail2ban logtarget /var/log/fail2ban.log, dbfile /var/lib/fail2ban/fail2ban.sqlite3, dbpurgeage 86400 seconds and systemctl is-enabled output enabled, 2026-10-26" - kind: repository repository: jupiter-stacks revision: working-tree @@ -33,6 +43,7 @@ unknowns: - wireguard-allowedips-and-keepalive - backup-and-restore-policy - uptime-kuma-exact-probes-and-alert-timing + - fail2ban-ban-escalation-action-details-log-rotation-and-recovery-access --- # Mercury VPS @@ -125,6 +136,119 @@ See [Observability](operations.md#observability) for container-alerting guidance - UFW allows TCP `22,80,443`; UDP `80,443,51820`. - Docker forwarding has separate rules; INPUT policy alone does not define container exposure. -- Fail2ban jails: `nginx-botsearch`, `nginx-http-auth`, `sshd`. +- Fail2ban version: `1.1.0`; three active jails: `nginx-botsearch`, + `nginx-http-auth`, `sshd`. Confirmed from owner-supplied CLI output on + 2026-10-26. + +Read-only commands to check the installed version and active jails: + +```bash +sudo fail2ban-client version +sudo fail2ban-client status +``` + +Effective jail settings from owner-supplied CLI output on 2026-10-26: + +| Jail | Retry threshold (`maxretry`) | Detection window (`findtime`) | Ban duration (`bantime`) | IP/network exemptions (`ignoreip`) | +| --- | --- | --- | --- | --- | +| `sshd` | 5 | 600 seconds (10 minutes) | 600 seconds (10 minutes) | None | +| `nginx-http-auth` | 3 | 600 seconds (10 minutes) | 600 seconds (10 minutes) | None | +| `nginx-botsearch` | 2 | 600 seconds (10 minutes) | 3600 seconds (1 hour) | None | + +These thresholds count filter-matched failures within the detection window, +not arbitrary requests. No IP/network is explicitly exempt through `ignoreip` +in any of the three jails; other ignore mechanisms have not been inspected. +Ban escalation settings and enforcement action details have not yet been +recorded. Avoid deliberate failed SSH login +tests without a recovery route: the administrator's IP has no `ignoreip` +exemption. + +### Fail2ban log sources / enforcement + +Owner-supplied runtime output on 2026-10-26 confirms: + +| Jail | Monitored source | Configured action | +| --- | --- | --- | +| `sshd` | systemd journal: `_SYSTEMD_UNIT=ssh.service + _COMM=sshd`; no log file monitored | `nftables` | +| `nginx-http-auth` | `/var/log/nginx/error.log`; no journal match set | `nftables` | +| `nginx-botsearch` | `/var/log/nginx/access.log`; no journal match set | `nftables` | + +The `+` in the SSH journal match is an OR: entries matching `ssh.service` or +the `sshd` command are selected. All three jails use the `nftables` action; +the action name alone does not establish the exact blocked ports, chains or +IPv4/IPv6 coverage. Those action parameters have not yet been inspected. + +### Fail2ban persistent configuration + +Owner-supplied non-comment configuration on 2026-10-26: + +`/etc/fail2ban/jail.local`: + +```ini +[nginx-botsearch] +enabled = true +port = http,https +filter = nginx-botsearch +logpath = /var/log/nginx/access.log +maxretry = 2 +findtime = 600 +bantime = 3600 + +[nginx-http-auth] +enabled = true +filter = nginx-http-auth +port = http,https +logpath = /var/log/nginx/error.log +maxretry = 3 +``` + +`/etc/fail2ban/jail.d/defaults-debian.conf`: + +```ini +[DEFAULT] +banaction = nftables +banaction_allports = nftables[type=allports] + +[sshd] +backend = systemd +journalmatch = _SYSTEMD_UNIT=ssh.service + _COMM=sshd +enabled = true +``` + +The nginx jails explicitly target `http,https`. Defining +`banaction_allports` does not establish that any active jail uses all-port +banning. The SSH thresholds and nginx HTTP auth timing in the runtime table +are not explicitly set in these snippets; they are inherited from other +configuration/defaults. + +These host configuration files are outside the Docker Compose stacks. Their +backup coverage and any direct edits to `jail.conf` or filter/action files +have not been confirmed. + +### Fail2ban logging / history + +Owner-supplied runtime settings on 2026-10-26: + +| Setting | Value | +| --- | --- | +| Fail2ban log destination (`logtarget`) | `/var/log/fail2ban.log` | +| Persistent database (`dbfile`) | `/var/lib/fail2ban/fail2ban.sqlite3` | +| Database purge age (`dbpurgeage`) | 86400 seconds (24 hours) | +| Start at boot (`systemctl is-enabled fail2ban`) | `enabled` | + +The purge age controls cleanup of old database ban history; it is not the ban +duration and does not define log-file retention. Log rotation and retained +log history have not yet been inspected. The database is not an established +long-term event archive, so a future historical ban-count widget must account +for cleanup and log rotation rather than treating it as complete history. + +Boot enablement does not by itself prove service health or successful +enforcement. Current bans can be inspected without changing configuration: + +```bash +sudo fail2ban-client status sshd +sudo fail2ban-client status nginx-http-auth +sudo fail2ban-client status nginx-botsearch +``` Rules and versions are supplied snapshots, not live inspection.