Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.** 127 ADRs covering what was chosen
- **Documented decisions and runbooks.** 128 ADRs covering what was chosen
and what was rejected — including the costs accepted knowingly; 53
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
Expand Down Expand Up @@ -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/ # 127 ADRs — architecture decision records
│ ├── adr/ # 128 ADRs — architecture decision records
│ ├── exercises/ # purple-team exercise records — see its README
│ └── runbooks/ # 53 runbooks; successor-handover.md is the front door
└── Makefile # make help
Expand Down
125 changes: 125 additions & 0 deletions docs/adr/0128-give-prometheus-a-key-only-sshd-and-no-host-firewall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# ADR-0128: Give `prometheus` a key-only `sshd` and no host firewall

**Status:** Accepted · 2026-11

## Context

`prometheus` holds more than any other host in the estate:

- the estate's CA key ([ADR-0043](0043-keep-the-ca-on-prometheus-and-build-phoenix-as-the-deployment-host.md)
keeps it here);
- the observability stack's age key, which opens every volume backup set;
- every metric and log the estate writes.

Converge runs here as the operator's account, which is in `sudo` and
`docker`. So whoever logs in as that account owns all three.

The root-only reads that finished the audit of 2026-11-13 were taken on
2026-11-23. They found the way in wider than on the hosts this one
administers:

- `sshd -T` reads `passwordauthentication yes`, from cloud-init's
`50-cloud-init.conf`, the only drop-in present;
- `x11forwarding yes`;
- `ufw` inactive, and no other host firewall.

`permitrootlogin no` and `permitemptypasswords no` already hold.

`phoenix` ([ADR-0117](0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md)),
`trinity`, `heimdall` and the lab's key holders (`alexander`, `odin`) all take
keys only. The host holding the CA and the age key that opens the backups is
the one that still takes a password.

Who reaches `22` here:

- **Hicks**, by `morpheus`'s pass for `22` to the whole of `10.0.99.0/24`
([`network.md`](../network.md), the Hicks table). The source is the segment,
so every household device on Hicks can try a password.
- **Every host on VLAN 99,** which `morpheus` never filters between.
- Sixty days of `ssh` journal show key logins from four Hicks addresses. They
also show two password logins from `trinity`, which the change below must
give a key first.

Docker publishes Grafana (`3000`) and speedtest-tracker (`8443`) on
`0.0.0.0`. On `10.0.99.20` it publishes the ingest proxy's `9090` and
`3100`, and Alloy's syslog listener on `6514`. Docker's rules run ahead of `ufw`'s for published ports, so a
`ufw` policy here would govern `22` alone. That was the finding on `trinity`
too (changelog, 2026-11-23).

## Decision

**`sshd` on `prometheus` is key-only.** A drop-in,
`/etc/ssh/sshd_config.d/10-prometheus.conf`, sorts ahead of cloud-init's
`50-cloud-init.conf`. `sshd` keeps the first value it reads, so the drop-in
wins without the installer's file being edited. It sets:

- `PasswordAuthentication no` and `KbdInteractiveAuthentication no`;
- `PermitRootLogin no`;
- `X11Forwarding no`.

`authorized_keys` keeps the machines the host is administered from: Hicks's
workstations, and `trinity`'s key if the operator still logs in from there.
Each proves a key login before the drop-in goes in. That ordering is the
whole risk of the change, so the runbook makes it a check rather than a
reminder.

**No host firewall, by decision,** as on `trinity`. The only port a `ufw`
policy would cover is `22`, and the key is the control there. The published
ports are fenced elsewhere:

- `morpheus` admits Hicks to `3000` and `8443` only;
- on `9090` and `3100`, the ingest proxy serves a push or a query only to a
token, over TLS
([#182](https://github.com/Gerrrt/HomeLab/issues/182),
[#764](https://github.com/Gerrrt/HomeLab/issues/764));
- on `6514`, Alloy's syslog listener takes TLS only, and only with
`morpheus`'s pinned client certificate. It keeps a line only when the
connection's source address is on its sender list
([#1049](https://github.com/Gerrrt/HomeLab/issues/1049),
[#844](https://github.com/Gerrrt/HomeLab/issues/844),
`stacks/observability/alloy/syslog.alloy`);
- Alertmanager and the rest bind to loopback.

A host firewall that did cover those ports would have to be written in
`DOCKER-USER`. A mistake there drops the agents' pushes from every host,
on the one host whose job is to notice that the others have gone quiet.

**Nothing converges host configuration here, so this is applied by hand.**
The step is [`restore-the-stack.md`](../runbooks/restore-the-stack.md)
§*Make `sshd` key-only*. Step 0 of a rebuild (§3) applies it in the same
place. The step ends with the checks that prove both halves.

## Alternatives considered

- **`ufw` default-deny, as on `phoenix`.** Declined. It would cover `22`
alone, because Docker's rules run first for every other port. On `22` it
would narrow the source to Hicks and VLAN 99, which is already everything
that can route here. It adds a second tool's state to read in every audit,
and no control.
- **Rules in `DOCKER-USER`** to narrow the published ports by source.
Declined for now. `morpheus` already narrows the Hicks side. On VLAN 99,
the ingest proxy's tokens bound the agents, and the syslog listener's
pinned certificate bounds `6514`. A wrong rule fails
silently, on the monitoring host itself.
- **`AllowUsers` naming the operator.** Not needed today. The host has one
login account, and the unused `prometheus` user has `/bin/false` (the
2026-11-13 audit's finding 7). Reopen it if a second login account appears.
- **Leave passwords on and rely on `morpheus`.** Declined. `morpheus`'s pass
is the whole of Hicks, a segment of household devices.

## Consequences

- **A lost key now locks a workstation out,** where before it fell back to a
password. The recovery path is the laptop's own keyboard and screen in the
rack, where a local login still takes a password.
- **`trinity`'s logins here need a key,** or stop. Its runbook already gives
`prometheus`'s key to `trinity`. The reverse direction is new.
- **The published ports keep their current fence:** `morpheus` by
destination, the ingest proxy by token, and the syslog listener by
certificate and sender address. This ADR does not change them.
- **Reopened by:**
- a host listener on something other than `22` that is not loopback;
- `morpheus`'s Hicks pass narrowing to named workstations, which would let
`sshd` or a firewall name them as well;
- a converger for host configuration, which would carry this drop-in
instead of the runbook.
23 changes: 23 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,29 @@ docstring gives: it is a record, not a claim about now.

## 2026-11-23

- **`prometheus` will take SSH keys only, and stays without a host firewall
([ADR-0128](adr/0128-give-prometheus-a-key-only-sshd-and-no-host-firewall.md)).**
The root-only reads that finished the 2026-11-13 audit were taken today.
`sshd -T` read `passwordauthentication yes` and `x11forwarding yes`, from
cloud-init's drop-in, and `ufw` was inactive, on the host that holds the CA
key and the age key that opens every backup set. `restore-the-stack.md`
gains *Make `sshd` key-only*, the same drop-in `trinity` and `phoenix` use,
and §3 of a rebuild runs it first. No host firewall, as on `trinity`:
Docker's rules run ahead of `ufw`'s for the published ports, so a policy
would cover `22` alone. A new `security.md` row records both. The step was
applied the same evening. `sshd -T` read `no` for all four settings, a
password login and a keyboard-interactive login were refused, and a key
login from Hicks succeeded after the reload. The same reads found the SSD reports only
`Wear_Leveling_Count`, normalised 178 against a threshold of 100, so it has
no wear percent and no `homelab_smart_percentage_used` series, which is
correct.
The rest of the audit's finding 8 was applied too. `ModemManager`,
`udisks2`, `multipathd` and `bolt` are masked, and `b43`, which loaded
without firmware for the unused BCM4331 Wi-Fi on every boot, is
blacklisted with its two buses. After that, no unit had failed, no target
was down, and the USB NIC stayed up. `restore-the-stack.md` gains *Trim what
the laptop does not use*, so a rebuild does the same.

- **The range host will be monitored now that it stays on
([ADR-0126](adr/0126-monitor-gandalf-now-that-it-stays-on.md),
[#1651](https://github.com/Gerrrt/HomeLab/issues/1651)).** ADR-0125 made
Expand Down
87 changes: 87 additions & 0 deletions docs/runbooks/restore-the-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ make up

Same, without `--only`. On a rebuilt host, do it in this order:

0. Make `sshd` key-only first, before the host holds the age key
([Make `sshd` key-only](#make-sshd-key-only)).
Then [trim what the laptop does not use](#trim-what-the-laptop-does-not-use).
1. If `prometheus` is what died, or is unreachable, take the set from `oracle`
first. The age key is not there; bring it from its offline copy
([`back-up-the-age-key.md`](back-up-the-age-key.md)):
Expand Down Expand Up @@ -311,6 +314,90 @@ curl -sG http://localhost:9090/api/v1/query \

---

## Make `sshd` key-only

[ADR-0128](../adr/0128-give-prometheus-a-key-only-sshd-and-no-host-firewall.md):
`prometheus` holds the CA key and the age key that opens every backup set, and
`22` answers all of Hicks and VLAN 99. It has no host firewall by decision, so
this drop-in is the control on `22`. The installer's OpenSSH takes passwords,
and cloud-init's `50-cloud-init.conf` keeps it that way.

Keep `~/.ssh/authorized_keys` to the machines you administer the host from:
Hicks's workstations, and `trinity` if you log in from there. Install any that
is missing now, from that machine, while a password still works:

```bash
ssh-copy-id <you>@10.0.99.20
```

Then prove a fresh key login from each one. Each must succeed with no password
prompt; fix that machine's key first if it does not, because the next step
takes away the password it would otherwise fall back on:

```bash
ssh -o ControlPath=none -o PreferredAuthentications=publickey -o PasswordAuthentication=no <you>@10.0.99.20 true
```

Log in with a key and keep that session open while you do the rest, so a
mistake cannot lock you out. If one does, the laptop's own keyboard in the
rack still takes a password.

```bash
sudo tee /etc/ssh/sshd_config.d/10-prometheus.conf > /dev/null <<'EOF'
# Keys only (ADR-0128, restore-the-stack.md). Sorts ahead of
# 50-cloud-init.conf, and sshd keeps the first value it reads, so these win.
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
X11Forwarding no
EOF
sudo sshd -t && sudo systemctl reload ssh
sudo sshd -T | grep -E '^(passwordauthentication|kbdinteractiveauthentication|permitrootlogin|x11forwarding) '
```

All four read `no`. Then, from Hicks, in a new terminal, prove both halves.
`ControlPath=none` makes each probe open a fresh connection instead of riding
on the session you kept open:

```bash
ssh -o ControlPath=none -o PubkeyAuthentication=no -o PreferredAuthentications=password <you>@10.0.99.20 true
```

```bash
ssh -o ControlPath=none -o PreferredAuthentications=publickey -o PasswordAuthentication=no <you>@10.0.99.20 true
```

The first must fail with `Permission denied (publickey)`, and the second must
succeed.

---

## Trim what the laptop does not use

The 2012 MacBook Pro boots with services and a driver that have no job here.
They were masked on 2026-11-23, and a rebuild does the same:

- `ModemManager`: there is no modem.
- `udisks2`: there is no removable media to mount.
- `multipathd` and its socket: there is one SATA disk and no SAN.
- `bolt`: there is no Thunderbolt device. The NIC is the USB `r8152` adapter,
so this is safe. If a Thunderbolt adapter ever carries the network, unmask
`bolt` first, or the adapter is never authorised.
- `b43`, with the `bcma` and `ssb` buses it loads: the BCM4331 Wi-Fi is unused,
and `b43` has no firmware for it, so it only logs errors at boot.

```bash
sudo systemctl mask --now ModemManager.service udisks2.service multipathd.service multipathd.socket bolt.service
printf 'blacklist b43\nblacklist bcma\nblacklist ssb\n' | sudo tee /etc/modprobe.d/blacklist-b43-prometheus.conf
sudo modprobe -r b43 bcma ssb
lsmod | grep -E '^(b43|bcma|ssb) ' || echo none
```

Expect `none`, and `systemctl is-enabled` reading `masked` for each unit.
`systemctl unmask` undoes any of them.

---

## The media tier's state is a different set

`make restore` and everything above it read `backups/volumes/`, the sets of
Expand Down
1 change: 1 addition & 0 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ What this network is actually built to survive:
| A range target with a path out | It has none — `gandalf`'s targets sit on a bridge with no physical port, on `172.30.30.0/24`, which the firewall does not route and on which nothing has a default route at all ([ADR-0014](adr/0014-put-ifrit-on-imaginationlan-and-give-the-targets-no-route.md), [ADR-0017](adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md)) |
| A rooted range target reaching `gandalf` itself | **Dropped at `vmbr1`, before the host firewall, once applied.** 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. Nothing watches that firewall on `gandalf`. 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. **The table and the tooling removal are not yet applied** |
| 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 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 | 192 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 |
Expand Down