Fix SOPS_AGE_SSH_PRIVATE_KEY_FILE for age recipients #2009
+434
−29
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.
Fixes #1999
Problem
Users who convert their SSH public keys to age recipients using
ssh-to-agecannot decrypt withSOPS_AGE_SSH_PRIVATE_KEY_FILE. This is a common workflow for reusing existing SSH keys with SOPS.Example workflow that fails:
Root Cause
SOPS only creates an SSH identity from the key file. SSH identities can decrypt data encrypted to SSH recipients, but NOT data encrypted to age X25519 recipients (even when derived from the same key).
Solution
For ed25519 SSH keys, now create both:
The conversion uses the same algorithm as
ssh-to-age: ed25519 -> curve25519 -> bech32-encoded age identity.Encrypted (passphrase-protected) SSH keys were already supported - this fix extends that to also create the age identity. The passphrase prompt behavior changes slightly: it's now requested once upfront (instead of lazily via callback) so it can be reused for creating both identities.
Non-ed25519 keys (RSA, ECDSA) are unchanged - they only get an SSH identity. age uses X25519 which is based on Curve25519, the same curve as ed25519, making conversion possible only for ed25519 keys.
Changes
age/bech32/age/ssh_parse.goed25519PrivateKeyToCurve25519,sshEd25519ToAgeIdentity, extractparseEncryptedSSHKeyage/keysource.goage/keysource_test.goTest Plan