Fix sops-nix host decrypt: use age-converted pubkeys, not raw ssh-ed25519 - #242
Merged
Conversation
…5519 k3s-sops-operator-seed.service failed on node1 with "Error getting data key: 0 successful groups required, got 0" when decrypting secrets/clusters/prd/sops-age-key.sops, even though node1's SSH host key was a correctly listed recipient and sops updatekeys/rotate reproduced the exact same failure every time. Root cause: sops's own "ssh-ed25519 ..." recipient support (filippo.io/age/agessh, meant for a human decrypting locally via SOPS_AGE_SSH_PRIVATE_KEY_FILE) and sops-nix's host-side decrypt (Mic92/ssh-to-age, used by sops-install-secrets) derive *different* X25519 keys from the same ed25519 SSH key. Confirmed reproducibly with a throwaway test keypair: ciphertext encrypted via filippo.io/age/agessh for a recipient never decrypts via the Mic92-derived identity for that same key. sops-nix's own README documents the correct pattern: convert a host's SSH key to its age1... form with ssh-to-age first, and use that string as the recipient, not the raw SSH pubkey. modules/flake/sops-config.nix's clusterMemberHostKeys was inserting a cluster-member host's raw SSH pubkey as an age recipient on secrets/clusters/<cluster>/sops-age-key.sops, which sops-nix on that host can never actually decrypt. provision-host-key.nix now also derives and commits each host's age-converted pubkey (ssh_host_ed25519_key.age-pub), and sops-config.nix uses that instead. Backfilled node1's age-pub, regenerated .sops.yaml, and rotated the cluster secret to the corrected recipient. Verified on node1: k3s-sops-operator-seed.service now succeeds. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CezjyaVpC3FVPTUECp7cMR
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CezjyaVpC3FVPTUECp7cMR
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.
Summary
k3s-sops-operator-seed.servicefailed on node1 withError getting data key: 0 successful groups required, got 0when decryptingsecrets/clusters/prd/sops-age-key.sops— even though node1's SSH host key was correctly listed as a recipient, andsops updatekeys/sops rotatereproduced the exact same failure every time (ruling out a one-off bad ciphertext blob).sops's ownssh-ed25519 ...recipient support (filippo.io/age/agessh, meant for a human decrypting locally viaSOPS_AGE_SSH_PRIVATE_KEY_FILE) andsops-nix's host-side decrypt (Mic92/ssh-to-age, used bysops-install-secrets) derive different X25519 keys from the same ed25519 SSH key. Confirmed reproducibly with a throwaway test keypair: ciphertext encrypted viafilippo.io/age/agesshfor a recipient never decrypts via theMic92-derived identity for that same key.sops-nix's own README documents the correct pattern — convert a host's SSH key to itsage1...form withssh-to-agefirst, and use that string as the recipient, not the raw SSH pubkey.modules/flake/sops-config.nix'sclusterMemberHostKeyswas inserting a cluster-member host's raw SSH pubkey as an age recipient onsecrets/clusters/<cluster>/sops-age-key.sops, whichsops-nixon that host can never actually decrypt.provision-host-key.nixnow also derives and commits each host's age-converted pubkey (ssh_host_ed25519_key.age-pub), andsops-config.nixuses that instead. Backfilled node1'sage-pub, regenerated.sops.yaml, and rotated the cluster secret to the corrected recipient.Test plan
nix flake check --print-build-logspassesfilippo.io/age/agesshencrypt ->Mic92/ssh-to-agedecrypt fails; not committed, test-only)deploy node1) — no activation errorsk3s-sops-operator-seed.servicenow succeeds on node1:secret/sops-age-prd createdhttps://claude.ai/code/session_01CezjyaVpC3FVPTUECp7cMR