Secrets (sops-nix)
All network secrets (passwords, keys, tokens) live encrypted in a single file, managed by sops-nix 🡕. It is versioned in git in encrypted form; only key holders can decrypt it.
# usr/secrets/secrets.yaml (encrypted at rest)default-password: ...default-password-hash: ...user: alice: password-hash: ...The two keys
Section titled “The two keys”Decryption relies on two age 🡕 keys:
| Key | Where | Role |
|---|---|---|
| Admin key | ~/.config/sops/age/keys.txt | Edit secrets from the admin workstation |
| Infra key | /etc/sops/age/infra.key | Decrypt on each host at deploy time |
- The admin key derives from your SSH key (
~/.ssh/id_ed25519, viassh-to-age). - The infra key is generated once, then pushed to each host.
- Recipients are listed in
usr/secrets/.sops.yaml(admin + infra).
Initialize (admin workstation)
Section titled “Initialize (admin workstation)”A single command prepares all the secrets infrastructure:
just configure-admin-hostIt is idempotent and creates, if needed:
- the deployer SSH key (
nix); - the admin key (from the SSH key) and the infra key (
age-keygen); - the
.sops.yamlfile (recipients); - a default password (
just passwd-default); - the Harmonia binary cache signing key.
Manage passwords
Section titled “Manage passwords”| Command | Effect |
|---|---|
just passwd-default | (Re)sets the default password for accounts |
just passwd <user> | Sets a user’s password |
just passwd-restic | Generates backup secrets (per host / zone) |
just sops | Edits the secrets file manually ($EDITOR) |
After a change, deploy to propagate it:
just passwd alicejust apply @user-alice # deploys the new hashPush the key to a host
Section titled “Push the key to a host”A host can only decrypt secrets with the infra key. It is placed automatically
by just configure <host>, or manually:
just push-key <host> # copies /etc/sops/age/infra.key to the hostRotating the infra key
Section titled “Rotating the infra key”Rotation replaces the infra key across the entire fleet, in three verified steps:
-
Introduce the new key
Fenêtre de terminal just rotate init # new key + re-encryption (old + new) -
Distribute to all hosts
Fenêtre de terminal just rotate push-keys # each host receives both keysjust apply '*' -
Finalize
Fenêtre de terminal just rotate finalize # discards the old key (after verification)just apply '*'