Kanidm unix client on thinks and pis: SSH login with personal Kanidm accounts #17

Open
opened 2026-11-07 23:47:54 +00:00 by ginjiruu · 0 comments
Owner

The only interactive path into the fleet is one workstation key (modules/admin-keys/id_rsa.pub, the admin user in modules/base.nix). One key, one person, no revocation. Kanidm (auth.animeteamspeak.moe) already authenticates k8s and HTTP for this lab. Put the Kanidm unix client on the thinks and the pis so people sign in with their own account and their own SSH key.

Server-side groundwork is lab/iac#48 (Kanidm Terraform): the posix groups, per-person SSH keys, and the unixd auth path must exist before the fleet rolls this on.

The module

  • New block modules/kanidm-unix.nix → services-kanidm-unix, option-gated, enabled on think-01..03 and pi-01..04 only. mini-01, game-01, and test-01 stay off; enabling them later is one line per host. The installer image never carries it: the recovery path cannot depend on the IdP.
  • The pinned nixpkgs services.kanidm module already provides the client half (unix.enable needs no server.enable): unixd + tasks units, /etc/kanidm/{config,unixd}, NSS ordering (kanidm before files), pam_kanidm in every service stack, and unix.sshIntegration wiring AuthorizedKeysCommand through the setuid kanidm_ssh_authorizedkeys wrapper. This block configures it, it does not reimplement it.
  • client.settings.uri = https://auth.animeteamspeak.moe (unixd reads it even without client.enable).
  • unix.settings.kanidm.pam_allowed_login_groups = [<login group>]. Login is opt-in; a Kanidm web user gets nothing by existing.
  • Sudo: unixd map_group maps the Kanidm admins group onto local wheel. With wheelNeedsPassword = false, mapped people get NOPASSWD root.
  • Pin services.kanidm.package = pkgs.kanidm_1_x to the same minor as the kanidm-mini image in flux-clusters. The bare kanidm alias is gone in this pin.
  • Break-glass untouched: admin keeps working (sshd checks AuthorizedKeysFile before AuthorizedKeysCommand), PasswordAuthentication stays off, Kanidm people live in NSS only, users.mutableUsers stays false.
  • Cache: unixd caches accounts and keys. Cached people log in with kanidmd unreachable; a new or rotated key needs the server reachable once.

Fleet hazards

  • A Pi cannot compile kanidm (large Rust build). After the push: task cache:push HOSTS='pi-01 pi-02 pi-03 pi-04' then task comin:retry, same drill as the cross kernel (AGENTS.md).
  • base.nix forces security.pam.services.sshd.startSession = false. The account stack still gates login, but first-login home-dir creation must be proven over plain ssh (tasks daemon), not only at a console.
  • Revocation latency = unixd cache TTL. Measure it, document it.
  • Kanidm posix UIDs are sparse (billions); verify no collision with admin (1000).
  • This flips PAM+nsswitch on 7 hosts. Prove on the harness VM (task vm:e2e), then one think, then the rest, task fleet:status to 7/7.

Done when

  • services-kanidm-unix exists, enabled on thinks+pis only
  • A second person signs in to think-01 and one pi with their own Kanidm key, sudo from the mapped group
  • Deleting their key in Kanidm revokes ssh within a measured TTL
  • admin key works with kanidmd unreachable
  • Pi roll with zero on-board kanidm builds, fleet:status 7/7
  • docs/kanidm-unix.md: grant and revoke procedure
> The only interactive path into the fleet is one workstation key (`modules/admin-keys/id_rsa.pub`, the `admin` user in `modules/base.nix`). One key, one person, no revocation. Kanidm (`auth.animeteamspeak.moe`) already authenticates k8s and HTTP for this lab. Put the Kanidm unix client on the thinks and the pis so people sign in with their own account and their own SSH key. Server-side groundwork is lab/iac#48 (Kanidm Terraform): the posix groups, per-person SSH keys, and the unixd auth path must exist before the fleet rolls this on. ## The module - New block `modules/kanidm-unix.nix` → `services-kanidm-unix`, option-gated, enabled on think-01..03 and pi-01..04 only. mini-01, game-01, and test-01 stay off; enabling them later is one line per host. The installer image never carries it: the recovery path cannot depend on the IdP. - The pinned nixpkgs `services.kanidm` module already provides the client half (`unix.enable` needs no `server.enable`): unixd + tasks units, `/etc/kanidm/{config,unixd}`, NSS ordering (`kanidm` before `files`), `pam_kanidm` in every service stack, and `unix.sshIntegration` wiring `AuthorizedKeysCommand` through the setuid `kanidm_ssh_authorizedkeys` wrapper. This block configures it, it does not reimplement it. - `client.settings.uri = https://auth.animeteamspeak.moe` (unixd reads it even without `client.enable`). - `unix.settings.kanidm.pam_allowed_login_groups = [<login group>]`. Login is opt-in; a Kanidm web user gets nothing by existing. - Sudo: unixd `map_group` maps the Kanidm admins group onto local `wheel`. With `wheelNeedsPassword = false`, mapped people get NOPASSWD root. - Pin `services.kanidm.package = pkgs.kanidm_1_x` to the same minor as the kanidm-mini image in flux-clusters. The bare `kanidm` alias is gone in this pin. - Break-glass untouched: `admin` keeps working (sshd checks `AuthorizedKeysFile` before `AuthorizedKeysCommand`), `PasswordAuthentication` stays off, Kanidm people live in NSS only, `users.mutableUsers` stays false. - Cache: unixd caches accounts and keys. Cached people log in with kanidmd unreachable; a new or rotated key needs the server reachable once. ## Fleet hazards - A Pi cannot compile kanidm (large Rust build). After the push: `task cache:push HOSTS='pi-01 pi-02 pi-03 pi-04'` then `task comin:retry`, same drill as the cross kernel (AGENTS.md). - `base.nix` forces `security.pam.services.sshd.startSession = false`. The `account` stack still gates login, but first-login home-dir creation must be proven over plain `ssh` (tasks daemon), not only at a console. - Revocation latency = unixd cache TTL. Measure it, document it. - Kanidm posix UIDs are sparse (billions); verify no collision with `admin` (1000). - This flips PAM+nsswitch on 7 hosts. Prove on the harness VM (`task vm:e2e`), then one think, then the rest, `task fleet:status` to 7/7. ## Done when - [ ] `services-kanidm-unix` exists, enabled on thinks+pis only - [ ] A second person signs in to think-01 and one pi with their own Kanidm key, sudo from the mapped group - [ ] Deleting their key in Kanidm revokes ssh within a measured TTL - [ ] `admin` key works with kanidmd unreachable - [ ] Pi roll with zero on-board kanidm builds, `fleet:status` 7/7 - [ ] `docs/kanidm-unix.md`: grant and revoke procedure
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#17
No description provided.