On key errors sops lists every recipient of the file with its result. That list is the most important information: it shows which key would be needed – and that yours isn't among them.
Symptom
sops decrypt prod/notes-db.yaml 2>&1 | head -9
Failed to get the data key required to decrypt the SOPS file.
Group 0: FAILED
age1r025nv6kv083tjhqa7xpslvkc0m8qm2jljd0aqn55nzr859xqe7q4798ks: FAILED
- | failed to create reader for decrypting sops data key with
| age: no identity matched any of the recipients. Did not find
| keys in locations 'SOPS_AGE_SSH_PRIVATE_KEY_FILE',
| 'SOPS_AGE_SSH_PRIVATE_KEY_CMD', '/home/ubuntu/.ssh/id_rsa',
| 'SOPS_AGE_KEY', 'SOPS_AGE_KEY_FILE', and 'SOPS_AGE_KEY_CMD'.
The message names the recipient for which a key is missing, and every location where sops looked.
Diagnosis
Compare the file's recipients with your public key. age-keygen -y tells you which key is which.
for k in ~/sops/tag04/prod.key ~/sops/tag06/ben.key; do echo "$(basename $k): $(age-keygen -y $k | cut -c1-12)…" done prod.key: age1r025nv6k… ben.key: age1z32l8zxd…
Causes
updatekeysRecipient only added to .sops.yaml
.sops.yaml only takes effect when encrypting and with updatekeys. Adding a recipient to the rule and committing changes nothing about existing files.
XDG_CONFIG_HOME=/nirgends SOPS_AGE_KEY_FILE=~/sops/tag01/kollegin.key \ sops decrypt dev/notes-db.yaml 2>&1 | grep -E 'Group|FAILED' Group 0: FAILED age1rnz4tqupd0f3lm4kfs564cfgys5j80497rk7ajzn2ekxh3d2g3uqdtdnv2: FAILED age1ymx7x29j3nctlanp5kwt76xve66dc0dm4lpklcq5jykxr7vq55fsmhu7ts: FAILED
PermissionYou're not a recipient – and aren't meant to be
If your key is neither in the list nor in the rule, it's a permissions question, not a technical fault. With OpenBao Transit and no token you also get a 403.
env -u VAULT_TOKEN XDG_CONFIG_HOME=/nirgends SOPS_AGE_KEY_FILE=~/sops/tag06/ben.key \
sops decrypt prod/notes-db.yaml 2>&1 | grep -E 'FAILED|Code'
Group 0: FAILED
age1r025nv6kv083tjhqa7xpslvkc0m8qm2jljd0aqn55nzr859xqe7q4798ks: FAILED
http://172.16.0.182:30820/v1/transit/keys/sops: FAILED
| Code: 403. Errors:Key locationKey exists but isn't found
sops looks in fixed locations. If the matching key lives elsewhere, pass it with SOPS_AGE_KEY_FILE, SOPS_AGE_KEY_CMD or SOPS_AGE_KEY.
Fix
sops updatekeys -y dev/notes-db.yaml 2>&1 | tail -1 | cut -c21- XDG_CONFIG_HOME=/nirgends SOPS_AGE_KEY_FILE=~/sops/tag01/kollegin.key \ sops decrypt --extract '["metadata"]["name"]' dev/notes-db.yaml File /home/ubuntu/sops/tag14/klon/dev/notes-db.yaml synced with new keys notes-db
Don't: Only changing .sops.yaml and committing. Without sops updatekeys the recipients of existing files stay as they were.
SOPS, day 14: recognise eight typical failures with sops and Sealed Secrets by their message and fix them without losing values.
Go to day 14 →
FAQ
I added the recipient to .sops.yaml – why doesn't it work?
sops updatekeys is missing. .sops.yaml says nothing about the file itself, only how it gets encrypted again.
What does the list under Group 0: FAILED show?
The file's recipients – every key that could open it, with its result.