Secrets #
Every secret in this repo is committed encrypted with sops. This page covers who
can decrypt, where the encrypted files are, how recipes use them without writing plaintext, and how to change
recipients. Restic credentials are covered in k8up.md, and kubeconfig handling in
AGENTS.md.
Recipients #
.sops.yaml has one creation rule with no path filter, so every file you encrypt in this repo gets
the same recipients:
- One age key. It is the backup key, and the private half is in 1Password.
- The team's PGP keys, by fingerprint.
just list-pgpshows your local keyring.just import-pgp [keyserver]imports every fingerprint in.sops.yaml, fromhkps://keys.openpgp.orgby default.
No encrypted_regex is set, so sops encrypts every value. Keys stay readable, which keeps diffs reviewable.
Where the files are #
.env.<host>.sops.yaml: per-host env, mainlyRESTIC_REPOSITORY,RESTIC_PASSWORD, and the S3 credentials.<host>/k3s-cert.sops.yaml: cluster-admin kubeconfig.<host>/services/<svc>/*.sops.yamlandcommon/services/<svc>/*.sops.yaml: complete KubernetesSecretmanifests withstringData, for examplesecrets.sops.yamlandk8up-credentials.sops.yaml.locally0/services/nanomq/nanomq_pwd.sops.conf: the NanoMQ password file. It is not YAML.common/tailscale/acl.sops.jsonc: the tailnet ACL.infra/.env.sops.yamlandinfra/state/prod/terraform.tfstate.sops: Terraform credentials and state.
List them all with:
git ls-files | grep -E '\.sops(\.|$)' | grep -v '^\.sops\.yaml$'
Using secrets without plaintext on disk #
- Env for a command:
SOPS_ENV_FILE=<file> just _env "<command>"runs the command undersops exec-env --same-process. Always setSOPS_ENV_FILE. The default.env.sops.yamldoesn't exist, sojust _envwithout it fails. - Kubernetes secrets:
just apply-secret <host> <svc>/<file>.sops.yaml(orapply-common-secret) pipessops decryptintokubectl apply -f -. The service recipes use this. - Editing:
just edit-key <file>opens the decrypted file innanoand re-encrypts it on save. - New file: write the plaintext manifest, then run
sops encrypt --in-place <file>.sops.yamlbefore you stage it. Once a plaintext secret is committed, it stays in git history even after a later fix.
Some steps do write plaintext. Each one writes to a gitignored path:
just k3s-decrypt <host>writes<host>/k3s-cert.yaml. Everykubectlrecipe reads that file.just nanomqwritesnanomq_pwd.confand deletes it again. If the recipe fails partway, the file stays, andlocally0/services/nanomq/.gitignorekeeps it out of git.just decrypt-key <file>writes the file next to the original, with.sopsremoved from the name. Its prompt warns that it overwrites an earlier decrypted copy.
Changing recipients #
just update-keys, just rotate-keys, and just decrypt only cover .env.sops, infra/.env.sops, and
infra/secrets/dashboard-keys.sops.json. None of those paths exist any more, so the recipes fail, and they never
covered the per-host or per-service files anyway. Run sops over the full file list instead.
-
Edit
.sops.yamlto add or remove an age key or PGP fingerprint. -
Re-wrap every file for the new recipients.
updatekeyschanges who can unwrap each file's data key. It doesn't touch the encrypted values:git ls-files | grep -E '\.sops(\.|$)' | grep -v '^\.sops\.yaml$' | xargs -n1 sops updatekeys --yes -
When you remove a recipient, also rotate. A removed recipient may still hold the old data keys, so give every file a new one:
git ls-files | grep -E '\.sops(\.|$)' | grep -v '^\.sops\.yaml$' | xargs -n1 sops rotate --in-place -
Check the diff: every
*.sops*file should change only in itssops:metadata block (and, after a rotate, in its values). The header of.sops.yamlsays to sync recipient changes to the other repos that share these keys.
Re-encrypting doesn't change the secret values inside the cluster, so you don't need to re-apply anything after a recipient change.