sops with rypt
sops encrypts the values in a YAML, JSON or dotenv file under a
data key it makes for that file, and keeps the data key in the file, encrypted once for
each recipient you list. With age-plugin-rypt, a rypt key can
be one of those recipients: sops keeps that recipient's copy of the data key
age-encrypted, and the plugin has rypt encrypt the copy's file key when sops makes or
re-encrypts the file's data key, and decrypt it when sops reads the file. Your values
do not reach rypt, but the key that opens them does, so this is not zero-knowledge.
This page sets up files with two recipients: a rypt key, and an offline recovery key that opens them without rypt.
What you need
Section titled "What you need"- sops 3.10 or later, the first release that supports age plugins. sops has age built
in, so it needs no
agecommand. - age-plugin-rypt, on the PATH of the shell that runs sops. It runs on Linux and macOS only.
age-keygen, which comes with age, to make the recovery key.
sops --version --disable-version-check; age-plugin-rypt --version
sops 3.13.3
age-plugin-rypt 0.2.0
The output on this page is from these versions, on Linux.
The API token it needs
Section titled "The API token it needs"The plugin reads the API token from RYPT_TOKEN. It calls encrypt when sops encrypts
a file's data key, and decrypt when sops opens it:
- A machine that creates files or changes their recipients needs
encryptanddecrypt. The quickstart's API token has exactly these. - A machine that never creates files or changes their recipients, CI among them, needs
decryptalone. With it,sops decrypt,exec-envandexec-filework, and so doeditandset, since they keep the file's data key: such an API token can still change the values.sops encrypt,updatekeysandrotateare refused.
Issue the API token as in issue an API token, and put it
in RYPT_TOKEN and the key's id in KEY_ID as that step shows.
The API token it needs on the
age-plugin-rypt page shows how to hold it to one key, and why unwrap does not work in
place of decrypt.
Set up
Section titled "Set up"On each machine that reads or writes the files, add a rypt identity to the keys file
sops reads, and print the identity's recipient. KEY_ID holds the key's id, as after
the quickstart:
mkdir -p ~/.config/sops/age && age-plugin-rypt new --key "$KEY_ID" >> ~/.config/sops/age/keys.txt && age-plugin-rypt recipient ~/.config/sops/age/keys.txt
age1rypt1pu0z60zttf5h3puk5k6v85hp7qcmk36k
age-plugin-rypt new and recipient make no call to rypt, and neither the identity nor
the recipient is a secret: both hold only the key's id. When XDG_CONFIG_HOME is set,
on Linux or macOS, sops reads $XDG_CONFIG_HOME/sops/age/keys.txt: put
"$XDG_CONFIG_HOME/sops/age" in place of ~/.config/sops/age in the command. On macOS
without it, sops reads ~/Library/Application Support/sops/age/keys.txt: put
"$HOME/Library/Application Support/sops/age", with the quotes, in place of
~/.config/sops/age in the command. >> keeps any identities already in the file. If
the file already held a rypt identity, recipient prints a line for each, and the new
one is last. Never indent a line in it: sops then loads nothing from the file.
Once, on one machine, make the recovery key, and note the public key it prints:
age-keygen -o backup.key
Public key: age15wvh68yrlmyf3r4re3sxn3eyuwe8g0axcm93txyv0la7uawttpjsz09cdh
Then write .sops.yaml at the top of the repository, with a creation rule for files
named *.enc.env, *.enc.yaml, *.enc.yml or *.enc.json, and both recipients, rypt
first, with the recipient and the public key you printed in place of these:
creation_rules:
- path_regex: \.enc\.(env|ya?ml|json)$
age:
- age1rypt1pu0z60zttf5h3puk5k6v85hp7qcmk36k
- age15wvh68yrlmyf3r4re3sxn3eyuwe8g0axcm93txyv0la7uawttpjsz09cdh
sops tries the recipients in this order when it reads a file, so with rypt first, each
read goes through rypt whenever rypt can answer, and shows in the key's audit log.
Move backup.key off this machine before you commit anything: it is the recovery key's
secret, and age-keygen wrote it to the current directory, which may be the repository
(decrypt with the recovery key). .sops.yaml holds no
secret: commit it.
Encrypt a file
Section titled "Encrypt a file"Write the values to a file whose name the rule does not match, such as secrets.env.
Here it holds DB_PASSWORD=change-me and API_BASE=https://example.com. sops picks the
rule by the name of the file it reads, so sops encrypt secrets.env > secrets.enc.env
fails with error loading config: no matching creation rules found, and the redirect
leaves an empty secrets.enc.env behind. Give the encrypted name with
--filename-override, and write the file with --output:
sops encrypt --filename-override secrets.enc.env --output secrets.enc.env secrets.env && rm secrets.env
The rm deletes the plaintext once the encrypted file is written. This costs 1
encrypt. Use --output rather than >: --output replaces the file only once sops
has succeeded, so when sops fails, as when rypt cannot be reached, an existing file is
left as it was, while > has emptied it before sops runs.
sops encrypts each value in place and adds its own sops_ keys, among them one
_map_recipient for each recipient, in the order of .sops.yaml:
grep _map_recipient= secrets.enc.env
sops_age__list_0__map_recipient=age1rypt1pu0z60zttf5h3puk5k6v85hp7qcmk36k
sops_age__list_1__map_recipient=age15wvh68yrlmyf3r4re3sxn3eyuwe8g0axcm93txyv0la7uawttpjsz09cdh
Commit secrets.enc.env. sops filestatus secrets.enc.env prints {"encrypted":true}
for an encrypted file, without calling rypt.
Read and edit a file
Section titled "Read and edit a file"sops decrypt secrets.enc.env
DB_PASSWORD=change-me
API_BASE=https://example.com
To print one value, name it with --extract. sops prints it with no newline after it,
so the echo adds one:
sops decrypt --extract '["DB_PASSWORD"]' secrets.enc.env; echo
change-me
Each costs 1 decrypt. sops edit secrets.enc.env opens the decrypted file in
$SOPS_EDITOR, or else $EDITOR, and encrypts it again when you save and close it;
here the edit changes change-me to changed. Saving encrypts the values under the
same data key, so an edit costs 1 decrypt and no encrypt. If you close the editor
without a change, sops prints File has not changed, exiting. and exits 200, and the
decrypt still counts.
Run a command with the values
Section titled "Run a command with the values"sops exec-env runs a command with the file's values in its environment, so they never
touch the disk. Here ./deploy.sh stands for your own command. The one run here is an
executable /bin/sh script that runs
test -n "$DB_PASSWORD" && echo "DB_PASSWORD is set", then
test -n "$RYPT_TOKEN" && echo "RYPT_TOKEN is set too", then exit 3:
sops exec-env secrets.enc.env './deploy.sh'; echo "exit $?"
DB_PASSWORD is set
RYPT_TOKEN is set too
exit status 3
exit 3
sops runs the command with /bin/sh -c, so put it in single quotes: then a $ name in
it expands in that shell, which has the file's values, not in yours. Only top-level
values can be passed: a nested one makes sops exec-env fail. The command's exit code
becomes sops's, and sops also prints it to standard error, as exit status 3.
The command gets the rest of your environment too, RYPT_TOKEN included, so it can call
rypt with your API token. To hold the API token back, start the command with
env -u RYPT_TOKEN inside the quotes, as the
restic page does. --pristine passes
the file's values alone, without even PATH or HOME.
sops exec-file hands a command the decrypted file instead, and replaces {} with its
path:
sops exec-file secrets.enc.env 'wc -l {}'
2 /tmp/.sops1115863172/tmp-file
The file is a named pipe that only you can read, in a new directory that sops removes
when the command ends. Give --no-fifo for a command that needs a regular file, such
as one that reads it twice. Each run of exec-env or exec-file costs 1 decrypt.
Add or remove a recipient
Section titled "Add or remove a recipient"To add a recipient, such as a teammate's age key, add its line to the age: list in
.sops.yaml and run sops updatekeys on each file. -y makes the change without
asking first:
sops updatekeys -y secrets.enc.env
2026/11/05 16:38:51 Syncing keys for file secrets.enc.env
The following changes will be made to the file's groups:
Group 1
age1rypt1pu0z60zttf5h3puk5k6v85hp7qcmk36k
age15wvh68yrlmyf3r4re3sxn3eyuwe8g0axcm93txyv0la7uawttpjsz09cdh
+++ age1c5vxfeakp7ged6rgrhz00p7tx0aqf3uu8mzuq48q9p5ntw6ytyhs5n2ust
2026/11/05 16:38:51 File secrets.enc.env synced with new keys
sops updatekeys decrypts the data key and encrypts it again to every recipient in the
rule, rypt included, so it costs 1 decrypt and 1 encrypt; the data key stays the
same. Run again with nothing to change, it reports already up to date and does not
call rypt.
To remove a recipient, delete its line from .sops.yaml and run sops updatekeys -y
again. The removed key could open the data key until then, so give the file a new one:
sops rotate -i secrets.enc.env
sops rotate -i decrypts the file, makes a new data key, encrypts every value again and
writes the file in place. It prints nothing and costs 1 decrypt and 1 encrypt. It
encrypts to the recipients the file already has, not to those in .sops.yaml, so run
updatekeys first. Copies of the file from before, in your git history among them, still
open with the removed key.
What each command needs and costs
Section titled "What each command needs and costs"The counts are per file, for a file with one rypt recipient as on this page.
| Command | Actions | Operations |
|---|---|---|
sops encrypt |
encrypt |
1 encrypt |
sops decrypt, sops exec-env, sops exec-file |
decrypt |
1 decrypt |
sops edit, saved or not, and sops set |
decrypt |
1 decrypt: they keep the data key |
sops updatekeys after a change to the recipients |
decrypt, encrypt |
2: 1 decrypt and 1 encrypt |
sops updatekeys with nothing to change |
none | 0 |
sops rotate -i |
decrypt, encrypt |
2: 1 decrypt and 1 encrypt |
sops filestatus, age-plugin-rypt new, age-plugin-rypt recipient |
none | 0 |
A read with the recovery key and RYPT_TOKEN unset |
none | 0 |
sops set changes one value from the shell; the
restic page shows it. A
request rypt refuses, or one that fails, costs nothing
(operations). rypt records each operation in the key's audit
log as encrypt or decrypt (what is recorded).
When something fails
Section titled "When something fails"sops keeps a copy of the data key for each recipient. When it reads a file, it tries the
copies in turn and moves to the next when one fails. If none opens, the read exits 128
and prints a block with a line for each recipient, trimmed here, with RYPT_TOKEN unset
and no recovery key:
env -u RYPT_TOKEN sops decrypt secrets.enc.env; echo "exit $?"
Failed to get the data key required to decrypt the SOPS file.
...
age1rypt1pu0z60zttf5h3puk5k6v85hp7qcmk36k: FAILED
- | failed to create reader for decrypting sops data key with
| age: rypt plugin: RYPT_TOKEN is not set.
...
exit 128
sops exec-env and sops exec-file then never run the command. A failed
sops encrypt exits 1 with Could not generate data key: and the plugin's message, and
leaves the file named by --output as it was.
Each cell shows the message that follows rypt plugin: , or Works. sops updatekeys
and sops rotate -i read the file and then encrypt it, so they work only where the
sops encrypt column says Works and the file can be read, through rypt or with the
recovery key.
| Situation | sops encrypt |
Reading through rypt | Reading with the recovery key |
|---|---|---|---|
| rypt cannot be reached | rypt: connection failed |
rypt: connection failed |
Works |
RYPT_TOKEN is not set |
RYPT_TOKEN is not set |
RYPT_TOKEN is not set |
Works |
| The API token is wrong or revoked | rypt: unauthorized |
rypt: unauthorized |
Works |
| The machine is outside the API token's firewall | rypt: unauthorized |
rypt: unauthorized |
Works |
The API token has decrypt only |
rypt: unauthorized |
Works | Works |
| A Free key is at its monthly cap | rypt: rate limit or op cap reached |
Works | Works |
| A paid key's billing is not in good standing | rypt: 402 |
Works | Works |
| The key is pending deletion | rypt: 409 |
rypt: 409 |
Works |
| The key is destroyed | rypt: key not found |
rypt: key not found |
Works |
| The file's key version is destroyed | Works | rypt: 400 |
Works |
At a Free key's monthly cap, rypt refuses to encrypt until 00:00 UTC on the 1st, and goes on decrypting. A paid key whose billing is not in good standing refuses to encrypt and goes on decrypting too (billing refusals).
A deleted key refuses every operation for 7 days, during which Restore on its page in the dashboard brings it back. After those 7 days, or at once with Delete now, the key is destroyed, and whatever was encrypted only to it can never be decrypted again. See one Free key per tenant and errors.
Decrypt with the recovery key
Section titled "Decrypt with the recovery key"Bring backup.key back from where you keep it to the directory that holds the file, and
name it in SOPS_AGE_KEY_FILE. Do not commit it. env -u RYPT_TOKEN runs sops without
the API token, to show that none is needed:
env -u RYPT_TOKEN SOPS_AGE_KEY_FILE="$PWD/backup.key" sops decrypt secrets.enc.env
DB_PASSWORD=changed
API_BASE=https://example.com
This makes no request to rypt, so it costs nothing and leaves no row in the audit log,
and it works the same when rypt cannot be reached. On sops 3.11 and later,
SOPS_AGE_KEY_FILE adds backup.key to the identities in keys.txt rather than
replacing them; 3.10 reads only the file it names. sops goes on to
the recovery key's copy after the rypt copy fails, so the order of identities does not
matter here; with the age command it does.
Move backup.key off the machine again when you are done.
A CI job that reads the files needs sops and
age-plugin-rypt on the runner's PATH, the rypt
identity and an API token. The identity holds no secret, so commit it: make it with
age-plugin-rypt new --key "$KEY_ID" > rypt-identity.txt, as in
make an identity and a recipient.
The API token is the only secret. Store it in the CI system's secrets as RYPT_TOKEN,
with decrypt alone and the key on its key list
(the API token it needs), and with a
firewall if the runners have fixed addresses. Name the
identity file in SOPS_AGE_KEY_FILE:
XDG_CONFIG_HOME="$PWD/empty" SOPS_AGE_KEY_FILE="$PWD/rypt-identity.txt" sops decrypt secrets.enc.env
DB_PASSWORD=changed
API_BASE=https://example.com
Here XDG_CONFIG_HOME points where there is no keys.txt, as on a fresh runner, so sops
loads only the committed identity; on a runner with no keys.txt, SOPS_AGE_KEY_FILE is
enough. This costs 1 decrypt, and sops exec-env works the same way. If the API token
leaks, see if an API token leaks.
After a rotation
Section titled "After a rotation"On a Free key every rotation retires the version before it; a retired version keeps decrypting for 7 days and is then destroyed (Free keys). A paid key keeps every version until you retire one (versions per tier).
A rotation does not change the key's recipient, so sops updatekeys finds nothing to
do. Run sops rotate -i on each file instead, as in
add or remove a recipient, before the retired version is
destroyed: it makes a new data key and encrypts it under the key's primary version. That
is 2 operations a file, and at a Free key's cap the encrypt half is refused, so first
check your usage with an API token that has read.
A file you miss still opens with
the recovery key: run sops rotate -i on it with SOPS_AGE_KEY_FILE naming
backup.key, which puts its new data key under the primary version, then move
backup.key off the machine again.
Errors
Section titled "Errors"| Message | Cause |
|---|---|
error loading config: no matching creation rules found |
No path_regex in .sops.yaml matches the file's name. To encrypt a file whose name does not match, give the encrypted name with --filename-override, as in encrypt a file. |
Failed to get the data key required to decrypt the SOPS file. |
Exit 128: no recipient's copy of the data key opened. The lines under it give each recipient's reason; for the rypt recipient, it is one of the plugin messages below. |
Could not generate data key |
Exit 1, from sops encrypt: the data key could not be encrypted to the rypt recipient. The line ends with the plugin's message, such as rypt plugin: rypt: connection failed. |
rypt plugin: RYPT_TOKEN is not set |
RYPT_TOKEN is unset or empty in the shell that runs sops. Set it as in the API token it needs. |
rypt plugin: rypt: unauthorized |
The API token is wrong, cut short or revoked (401 unauthorized); it lacks encrypt or decrypt (403 action_not_allowed); the key is not on its key list (403 key_not_allowed); the machine is outside its firewall (403 ip_not_allowed); or RYPT_TOKEN holds a dashboard session, not an API token (403 api_token_required). Change its actions, key list or firewall with Restrict on the API tokens page, or issue a new API token. |
rypt plugin: rypt: key not found |
404 not_found. The key id in the recipient or the identity is wrong, the key is in another container than the API token, or the key was destroyed. Check the key id in keys.txt and .sops.yaml against the Key id on the key's page in the dashboard, and issue the API token in the key's container (the pieces). A file whose key was destroyed opens only with the recovery key. |
rypt plugin: rypt: rate limit or op cap reached |
Either the API token's rate limit (429 rate_limited), or, when encrypting, a Free key's monthly cap (429 ops_cap_reached). The message does not say which: see telling the two 429s apart. |
rypt plugin: rypt: connection failed |
The plugin could not reach api.rypt.dev, or lost the connection, in 3 attempts. Check the network, and HTTPS_PROXY if you use a proxy. |
rypt plugin: couldn't start plugin: "rypt" plugin not found: exec: "age-plugin-rypt": executable file not found in $PATH |
sops cannot find the plugin. Install it, or add its directory to PATH in the shell that runs sops. |
failed to parse '.../keys.txt' age identities: unknown identity type |
A line in keys.txt is indented, or is not an identity or a # comment, so sops loads nothing from that file. Remove the leading spaces, and any line that is not an identity or a # comment. A line that ends in a space also stops sops loading the file, with another message in place of unknown identity type. |
cannot use complex value in environment; offending key nested |
sops exec-env passes only top-level values, and the key nested holds a map or a list. It exits 1 after the decrypt, which counts. Read such a value with sops exec-file or --extract. |
File has not changed, exiting. |
sops edit exits 200 when you close the editor without a change. Nothing is wrong, but the decrypt counts. |
exit status 3 |
The command that sops exec-env ran exited 3, and sops exits 3 too. |
The plugin's other messages, among them rypt: 400, rypt: 402 and rypt: 409, are
explained in age-plugin-rypt's errors.