Repository navigation
feat(tools): nix run .#rekey, replacing the age key safely - #62
Merged
Merged
Conversation
The documented steps were manual and in a risky order: push a re-encrypted secrets.yaml before every node had the new key, and their upgrades (and the in-cluster secrets job) can't decrypt it. rekey does it in two steps: the new key joins the old one on the workstation, every node and the cluster's copy, and secrets.yaml is encrypted for it (checked to open with the new key alone); --finish, refused until that's committed and pushed, removes the old key everywhere and sets the workstation's copy aside. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The documented re-keying steps were manual and in a risky order. Push a re-encrypted
secrets.yamlbefore every node has the new key, and their nightly upgrades (and the in-cluster nixlab-secrets job) can't decrypt it.nix run .#rekeydoes it in two steps, and nothing is ever unable to decrypt:rekey:nixlab-age-keyon the masters)secrets.yamlfor the new key, and checks that it opens with the new key alone and no longer with the old onerekey --finish:.sops.yamlandsecrets.yamlare committed and pushed (the nodes build what's pushed)<keyfile>.retired-<date>.Key files are swapped in atomically and stay read-only. If a node is unreachable, the first step stops before re-encrypting anything; rerun it later. The docs section is now three commands.
Test:
tool-rekeyruns the whole flow in the sandbox with real age, sops and git: a stubbed ssh stands in for the nodes, and a bare repository for the remote. It covers 15 steps: both keys work in between, the old key alone no longer opens the file, the finish is refused before the commit and before the push, one key is left everywhere afterwards, the old key is set aside, and a second run is a no-op.It wasn't run against the live cluster: rotating the owner's real key unattended isn't mine to do.
🤖 Generated with Claude Code