sshd certificate auth: per-zone TrustedUserCAKeys, host certs, cert-only mode, sudo via map_group #18

Open
opened 2026-11-08 00:15:17 +00:00 by ginjiruu · 2 comments
Owner

Host side of the SSH certificate epic (see machine-configs epic). Builds on modules/kanidm-unix.nix from #17; same option-gating discipline: thinks + pis first, mini/game/test later by one line per host.

Scope

  • New modules/ssh-ca.nix → services-ssh-ca: installs the zone's client CA public key to /etc/ssh/ca/, sets TrustedUserCAKeys, and the host cert + HostCertificate. Zone is a per-host option; one fleet zone at first.
  • Host key enrollment: sign /etc/ssh/ssh_host_ed25519_key.pub with the ssh-host-signer role at boot (first-boot script, key exists after ssh generation) or pre-generate host keys + certs in the image. Choose after proving timing in the harness; store the cert via OpenBao agent path, not in the store.
  • Certificate-only mode: AuthorizedKeysFile none (bare pubkeys refused), AuthorizedKeysCommand kept for service accounts / break-glass per #17. PasswordAuthentication, PermitRootLogin unchanged from base.nix.
  • networking.knownHosts: @cert-authority <fleet domain> <host CA pubkey> so every host trusts every host cert.
  • Workstation config: @cert-authority + a CertSign helper or documented bao write ssh-client-signer/sign/... flow.
  • sudo: confirm map_group kanidm-admins → wheel + wheelNeedsPassword = false; per-host sudoers stay in machine-configs keyed on kanidm groups (this is the "who runs what where" store now).
  • Rollout: vm:e2e → one think → rest of thinks → pis (task cache:push HOSTS='pi-01 pi-02 pi-03 pi-04' + task comin:retry before the Pi roll, AGENTS.md gotcha) → task fleet:status to 7/7. Break-glass admin login re-verified with kanidmd and OpenBao stopped, at every stage.

Hazards

  • Wrong-host flip locks interactive access: admin break-glass is the only door during rollout; never remove it.
  • The cert principal must equal the nss name exactly (getent passwd on a think decides; iac side templates follow, not the other way around).
  • Revocation latency: unixd cache TTL for group removal, cert TTL for live mint power. Measure both, document in docs/ssh-ca.md.
  • Host-key-at-boot vs cert-at-build timing: prove which side generates the host key before automating enrollment.

Done when

  • harness host accepts fleet-CA cert login as the kanidm principal, refuses bare pubkey and foreign CA
  • think-01 + one pi in cert-only mode, sudo from mapped group
  • fleet 7/7 cert-only, admin works with kanidmd and OpenBao down
  • docs/ssh-ca.md: mint flow, grant/revoke zone membership, CA rotation procedure
Host side of the SSH certificate epic (see machine-configs epic). Builds on `modules/kanidm-unix.nix` from #17; same option-gating discipline: thinks + pis first, mini/game/test later by one line per host. ## Scope - New `modules/ssh-ca.nix` → `services-ssh-ca`: installs the zone's client CA public key to `/etc/ssh/ca/`, sets `TrustedUserCAKeys`, and the host cert + `HostCertificate`. Zone is a per-host option; one fleet zone at first. - Host key enrollment: sign `/etc/ssh/ssh_host_ed25519_key.pub` with the `ssh-host-signer` role at boot (first-boot script, key exists after ssh generation) or pre-generate host keys + certs in the image. Choose after proving timing in the harness; store the cert via OpenBao agent path, not in the store. - Certificate-only mode: `AuthorizedKeysFile none` (bare pubkeys refused), `AuthorizedKeysCommand` kept for service accounts / break-glass per #17. `PasswordAuthentication`, `PermitRootLogin` unchanged from base.nix. - `networking.knownHosts`: `@cert-authority <fleet domain> <host CA pubkey>` so every host trusts every host cert. - Workstation config: `@cert-authority` + a `CertSign` helper or documented `bao write ssh-client-signer/sign/...` flow. - sudo: confirm `map_group` kanidm-admins → `wheel` + `wheelNeedsPassword = false`; per-host sudoers stay in machine-configs keyed on kanidm groups (this is the "who runs what where" store now). - Rollout: vm:e2e → one think → rest of thinks → pis (`task cache:push HOSTS='pi-01 pi-02 pi-03 pi-04'` + `task comin:retry` before the Pi roll, AGENTS.md gotcha) → `task fleet:status` to 7/7. Break-glass `admin` login re-verified with kanidmd and OpenBao stopped, at every stage. ## Hazards - Wrong-host flip locks interactive access: `admin` break-glass is the only door during rollout; never remove it. - The cert principal must equal the nss name exactly (`getent passwd` on a think decides; iac side templates follow, not the other way around). - Revocation latency: unixd cache TTL for group removal, cert TTL for live mint power. Measure both, document in `docs/ssh-ca.md`. - Host-key-at-boot vs cert-at-build timing: prove which side generates the host key before automating enrollment. ## Done when - [ ] harness host accepts fleet-CA cert login as the kanidm principal, refuses bare pubkey and foreign CA - [ ] think-01 + one pi in cert-only mode, sudo from mapped group - [ ] fleet 7/7 cert-only, `admin` works with kanidmd and OpenBao down - [ ] `docs/ssh-ca.md`: mint flow, grant/revoke zone membership, CA rotation procedure
Author
Owner

Parent epic: lab/machine-configs#19

Parent epic: lab/machine-configs#19
Author
Owner

Related: machine-configs#41 covers the RouterOS exception — routers cannot take host certs, so their raw keys ship in the same known_hosts file this module renders. Design the module so harvested device entries and the @cert-authority line compose from one option.

Related: machine-configs#41 covers the RouterOS exception — routers cannot take host certs, so their raw keys ship in the same known_hosts file this module renders. Design the module so harvested device entries and the @cert-authority line compose from one option.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/machine-configs#18
No description provided.