diff --git a/README.md b/README.md index 0cf7c394..e6fa28d2 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ documents for different readers. at all. Every pinned digest is also scanned weekly for fixable HIGH and CRITICAL CVEs, and each image with findings has an open issue until a scan finds it clean. -- **Documented decisions and runbooks.** 137 ADRs covering what was chosen +- **Documented decisions and runbooks.** 138 ADRs covering what was chosen and what was rejected — including the costs accepted knowingly; 57 runbooks for the operations that are easy to get wrong at 1am, one of which is the handover page a successor reads first. Every critical alert links to @@ -236,7 +236,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology │ ├── architecture.md network.md hardware.md │ ├── observability.md security.md roadmap.md changelog.md │ ├── diagrams/ # the network diagram (SVG) and its predecessors -│ ├── adr/ # 137 ADRs — architecture decision records +│ ├── adr/ # 138 ADRs — architecture decision records │ ├── exercises/ # purple-team exercise records — see its README │ └── runbooks/ # 57 runbooks; successor-handover.md is the front door └── Makefile # make help diff --git a/docs/adr/0045-pull-jellyfins-state-from-a-snapshot-over-ssh.md b/docs/adr/0045-pull-jellyfins-state-from-a-snapshot-over-ssh.md index ceef39c9..4e5bb93a 100644 --- a/docs/adr/0045-pull-jellyfins-state-from-a-snapshot-over-ssh.md +++ b/docs/adr/0045-pull-jellyfins-state-from-a-snapshot-over-ssh.md @@ -7,6 +7,14 @@ writes the first snapshot schedule decision 4 of asked for > [!NOTE] +> **A second SSH user, 2026-11.** `gerrrt`, the operator's administrator +> account, logs in by key from `desktop-02` and holds a checkout of this +> repository. Decision 4's "for this and nothing else" and the context's "no +> repository checkout" are amended by +> [ADR-0138](0138-keep-gerrrt-as-smaugs-administrator-account.md). The +> checkout is not a deploy path, and the host still holds no key that opens a +> backup. +> > **The pull reads a list, since 2026-09-22.** Audiobookshelf's state joins > Jellyfin's as a second archive in the same set, read from the same > snapshot, and `backup-nas.sh` now reads a table of archive → subpath where diff --git a/docs/adr/0138-keep-gerrrt-as-smaugs-administrator-account.md b/docs/adr/0138-keep-gerrrt-as-smaugs-administrator-account.md new file mode 100644 index 00000000..435292df --- /dev/null +++ b/docs/adr/0138-keep-gerrrt-as-smaugs-administrator-account.md @@ -0,0 +1,92 @@ +# ADR-0138: Keep `gerrrt` as `smaug`'s administrator account, with a checkout and no deploy path + +**Status:** Accepted · 2026-11 · amends +[ADR-0045](0045-pull-jellyfins-state-from-a-snapshot-over-ssh.md), +whose fourth decision opened SSH on `smaug` for `frodo` "and nothing else", +and whose context said the host has "no repository checkout" + +## Context + +ADR-0045 turned SSH on for one user, `frodo`, the backup pull's read-only +account, and recorded the host as having no checkout of this repository and +no key that opens anything. The documents kept saying so after both stopped +being true. + +The read-only audit of `smaug` on 2026-11-13 found a second account that no +document named: `gerrrt`, uid `3004`, with TrueNAS's `FULL_ADMIN` role, sudo +for every command, `zsh`, a home at `/mnt/erebor/apps/home/gerrrt`, an SSH +key, and in that home a checkout of this repository, the operator's dotfiles +and Claude Code, which the audit itself ran in. It logged in by password as +well as by key. `network.md` and `security.md` have since recorded the half +of this the firewall sees: the operator decided on 2026-11-23 to keep +`desktop-02` → `10.0.40.30:22` as the path `smaug` is administered by, and +password login was cleared on 2026-11-24. What no document decided is the +account itself: whether an interactive administrator with a checkout belongs +on the appliance that holds the backup datastore. + +The alternative is the shape ADR-0045 described: administer `smaug` from the +TrueNAS UI and its console shell as `truenas_admin`, carry nothing of this +repository on the box, and put every file the stack needs there through +[`smaug-fetch.sh`](../../scripts/smaug-fetch.sh), run on a workstation. That +works, and is what the runbooks still say. What it costs is that every audit, +every `midclt` read and every redeploy is done through the UI shell, by +pasting, from a machine that does not run the commands it prints. The +sessions of 2026-11-13 to 2026-11-25 did their reading, their patches and +the `smaug-fetch.sh` block for the redeploy from `gerrrt`, and none of it +needed to leave the box to be checked. + +## Decision + +**1. `gerrrt` stays, as `smaug`'s one interactive administrator.** It keeps +`FULL_ADMIN` and sudo for all commands. Sudo asks for the password every time: +no `NOPASSWD` entry, for any command. SSH is by key alone, and only from +`desktop-02`, by the host-scoped pass `network.md` records. `truenas_admin` +remains the UI's and the console's account, and is not used over SSH. + +**2. The checkout is for reading, and for printing what the box is given. It +is never a deploy path.** Files reach `/mnt/erebor/apps/stack` only as +`smaug-fetch.sh` installs them: fetched from a commit on `origin/main` and +checked against its sha256 before they replace anything. The checkout may +generate that block, but only from a clean tree at `origin/main`, which is +what the script already refuses otherwise. Nothing is copied from the +checkout into the stack directory, and nothing the stack runs points into +the home. + +**3. Nothing on `smaug` can push to this repository or decrypt its +secrets.** The checkout's push URL is SSH, and `gerrrt` holds no key GitHub +accepts. There is no `gh` and no token. A change found on the box leaves it +as a patch or a bundle and is pushed from a workstation, through review. +There is no `age` identity, so `secrets/*.sops.yaml` stay ciphertext here. +ADR-0045's property, that the host holds no key that opens a backup, is +unchanged. + +**4. A Claude Code session on `smaug` runs as `gerrrt` and is held to the +same rules as the operator.** It reads with `midclt`, `zpool`, `zfs` and the +textfile metrics. It changes the box only when the operator asks it to, and +records what it changed through the repository the way a runbook step is +recorded. It cannot use the Docker socket or sudo without the operator. + +## Consequences + +- **`gerrrt` is root for anyone who has its key and its password.** Sudo for + all commands means the key alone is not enough, and the key works only from + `desktop-02`. That is the residual, and `security.md` carries it. +- **The home is on `erebor/apps`, so it is in that dataset's snapshots.** A + session's transcript under `~/.claude` holds what the session read, kept + for the snapshot task's two weeks after it is deleted. One read on + 2026-11-13 printed the NUT monitor password into a transcript. Sessions + must read secrets by existence and permissions only, and a value that + reaches a transcript is rotated. The backup pull is not affected: it reads + only the subpaths its table names, and the home is not one of them. +- **The root-run scripts must stay owned by root.** On 2026-11-25 the + redeploy block was first run as `gerrrt`, which left the stack directory's + files owned by it until they were changed back. A `.sh` there that + `gerrrt` owns can be edited into root's cron without sudo. The block is + run as root, and an audit checks the owner. +- **The account must not outlive its use.** Turning `gerrrt` off is a UI + change: clear its role and its sudo, remove its key, and delete the home. + Nothing in the stack depends on it, and the pass on `morpheus` can go with + it. +- **The API key the audit found, `ClaudeCode2` on `truenas_admin`, is not + part of this decision.** No session in this account uses it. It is to be + revoked. diff --git a/docs/runbooks/build-the-nas.md b/docs/runbooks/build-the-nas.md index 900efde0..b6252c12 100644 --- a/docs/runbooks/build-the-nas.md +++ b/docs/runbooks/build-the-nas.md @@ -912,7 +912,10 @@ checkout of `main`, [`scripts/smaug-fetch.sh`](../../scripts/smaug-fetch.sh) prints a block that fetches each file from that one commit and checks it against a sha256 computed from your checkout before it replaces anything ([#1424](https://github.com/Gerrrt/HomeLab/issues/1424)). Paste that block -here. A file that does not match stops the block and is not installed; its +here, as root: run as `gerrrt`, it leaves root's cron scripts owned by an +account that can edit them +([ADR-0138](../adr/0138-keep-gerrrt-as-smaugs-administrator-account.md)). +A file that does not match stops the block and is not installed; its `.new` is left for you to look at. The `.env` is copied as-is, because every value in it is a plain host fact. The third file is the SMART collector §6.4 runs from cron diff --git a/docs/security.md b/docs/security.md index a72b4963..7a9b52f9 100644 --- a/docs/security.md +++ b/docs/security.md @@ -34,7 +34,7 @@ What this network is actually built to survive: | A rooted range target reaching `gandalf` itself | **Dropped at `vmbr1`, before the host firewall.** The host has no address on the range bridge, but Linux answers ARP for its addresses on any interface and accepts a packet for them on any interface. So a target that adds an on-link route to `10.0.30.30` was reaching the host, and only the Proxmox firewall dropped it. `gandalf`'s own `pve-firewall-state` collector watches that firewall now ([ADR-0126](adr/0126-monitor-gandalf-now-that-it-stays-on.md), [#1651](https://github.com/Gerrrt/HomeLab/issues/1651)). A netdev `ingress` table on `vmbr1` now drops every frame the bridge passes up to the host, ARP included, without touching guest-to-guest traffic ([`build-the-playground.md`](runbooks/build-the-playground.md) §2, proved by §8 check four). Behind it, `gandalf` holds no estate credential, no GitHub login, no personal tooling and no third-party apt repository (§4, *Nothing else on `gandalf`*), so the host gives nothing beyond itself. The audits of 2026-11-13 and 2026-11-22 found credentials, then tooling and two third-party repositories. The credentials were gone by 2026-11-22 and the `.claude` footprint by 2026-11-23. **The `vmbr1` table is applied (verified live).** Root's SSH key is Proxmox's node key; the audit found it had reached github, so it was regenerated fresh on 2026-11-23, minutes after a too-broad deletion that day briefly broke self-SSH ([changelog](changelog.md)). The new key is not one github recognises, so no host credential reaches the repository — revoking the old key on github, if it was ever a deploy key, is off-host | | Someone on Winterfell or Hicks logging in to `trinity` | **Key-only `sshd` since 2026-11-20; no host firewall by decision.** `trinity` holds the household's data and the sensitive tier's age key, and its `sshd` answers Hicks (by [ADR-0031](adr/0031-narrow-hicks-to-a-named-list-on-winterfell-and-leave-the-lab-open.md)'s list) and every host on VLAN 99, between which pfSense never filters. [`build-the-sensitive-tier-host.md`](runbooks/build-the-sensitive-tier-host.md) §3 now makes `sshd` key-only through a drop-in that outranks cloud-init's, refuses root and X11 forwarding, and keeps `authorized_keys` to `prometheus`'s key and Hicks's. The audit of 2026-11-13 found it taking passwords, with X11 forwarding on and 17 keys imported from GitHub. The step was applied on 2026-11-20: a password-only login is refused with `Permission denied (publickey)`, and three keys remain, `prometheus`'s, Hicks's and the operator's laptop, the last kept by decision. Agent sessions run on `trinity` as the operator, by decision ([ADR-0123](adr/0123-keep-agent-sessions-on-trinity.md)). `ufw` is installed and stays disabled, unlike `phoenix`'s ([ADR-0117](adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md)): the other two ports `trinity` answers, `443` and `53`, are published by Docker, whose rules run ahead of `ufw`'s, so a policy would govern `22` alone, which the drop-in already closes to anything without a key. Nothing routes through `trinity`, and as the spare firewall a host policy is one more thing to get in the way the day it stands in for `morpheus`. What reaches `443` and `53` is set by pfSense and by the stack's bind addresses | | Someone on Winterfell or Hicks logging in to `prometheus` | **Key-only `sshd` since 2026-11-23; no host firewall by decision.** `prometheus` holds the estate's CA key and the age key that opens every volume backup set, and converge runs as the operator, who is in `sudo` and `docker`. Its `sshd` answers all of Hicks (by `morpheus`'s pass for `22` to the segment) and every host on VLAN 99. The audit's root-only reads on 2026-11-23 found it taking passwords, with X11 forwarding on and `ufw` inactive. [ADR-0128](adr/0128-give-prometheus-a-key-only-sshd-and-no-host-firewall.md) makes `sshd` key-only through a drop-in that outranks cloud-init's, refusing root and X11 forwarding ([`restore-the-stack.md`](runbooks/restore-the-stack.md#make-sshd-key-only)). It adds no host firewall, because Docker's rules run ahead of `ufw`'s for the published ports, so a policy would cover `22` alone. Those ports stay fenced as before: by `morpheus` by destination, by the ingest proxy's tokens on `9090` and `3100`, and on `6514` by the syslog listener's pinned client certificate and its sender list. The step was applied the same day. `sshd -T` read `no` for all four settings, a password login and a keyboard-interactive login were each refused with `Permission denied (publickey)`, and a key login from Hicks succeeded after the reload. | -| Someone on Hicks or Winterfell logging in to `smaug` | **Key-only `sshd` since 2026-11-24.** `smaug` holds the household's media and the `erebor` pool. Two hosts reach its `22`, each by a host-scoped pass on `morpheus` ([`network.md`](network.md)): `prometheus`, as the read-only backup user `frodo`, and `desktop-02` on Hicks, as the administrator `gerrrt`. From 2026-11-13 `gerrrt` logged in by password, allowed both on the user and in the SSH service's *Password Login Groups*, while the documents said `frodo` was the only user. Both settings were cleared in the TrueNAS UI on 2026-11-24. `sshd_config` then had no `Match` block left, and a connection as `gerrrt` or `root` was offered `publickey` alone. | +| Someone on Hicks or Winterfell logging in to `smaug` | **Key-only `sshd` since 2026-11-24.** `smaug` holds the household's media and the `erebor` pool. Two hosts reach its `22`, each by a host-scoped pass on `morpheus` ([`network.md`](network.md)): `prometheus`, as the read-only backup user `frodo`, and `desktop-02` on Hicks, as the administrator `gerrrt`. From 2026-11-13 `gerrrt` logged in by password, allowed both on the user and in the SSH service's *Password Login Groups*, while the documents said `frodo` was the only user. Both settings were cleared in the TrueNAS UI on 2026-11-24. `sshd_config` then had no `Match` block left, and a connection as `gerrrt` or `root` was offered `publickey` alone. `gerrrt` is kept by [ADR-0138](adr/0138-keep-gerrrt-as-smaugs-administrator-account.md): `FULL_ADMIN` and sudo for all commands, with the password asked every time, and a checkout of this repository that can neither push nor decrypt. Its key and its password together are root on `smaug`; that is the residual. | | Someone with the trusted Wi-Fi key quietly joining | Kea's lease log reaches Loki; `UnknownDeviceOnTrustedSegment` fires the first time a MAC appears on VLAN 50 in seven days ([ADR-0019](adr/0019-read-device-joins-from-the-dhcp-server.md)) | | Losing visibility of a failure | 215 alert rules, 30 days of metrics and logs | | Someone on a reachable VLAN silencing an alert to hide a failure | Alertmanager binds to `127.0.0.1`; silences go through authenticated Grafana |