Skip to content

Secrets for a team

An encrypted secret is a file you can commit. Every person and machine that should read it has a key, and the value is encrypted to all their public keys, the workspace’s recipients. This guide covers the runy secret commands. The Secrets page explains the model.

Terminal window
runy secret key

prints this machine’s public key (age1...) and creates the key when it is missing. The private key is secrets.key in the state folder, readable by you only, and is created once and never replaced. A runy daemon inside a machine created from a pack has no key.

List the public keys in the workspace config, .runy.json:

{
"sources": [".runy"],
"recipients": {
"alice": "age1...",
"ci": "age1..."
}
}

The names are labels for you. A recipient that is not an age public key makes the config invalid.

Terminal window
printf '%s' "$GITHUB_TOKEN" | runy secret set github
runy secret get github
runy secret ls

set reads the value from stdin, drops one trailing newline and encrypts it to every recipient (none is an error). It replaces only the encrypted: block of the secret’s document, in the file the daemon read it from, and keeps the rest of the file as it was. A secret the daemon does not know yet is written as <source>/<name>.secret.yaml in the one source whose default namespace is the secret’s. When several sources hold that namespace, set fails with several sources hold that namespace: pass --source <folder>; --source <folder> or --file <yaml> resolves it. Pass -n <namespace> for another namespace, --source <folder> to choose the folder and --file <yaml> to name the file, which asks the daemon nothing. A secret that reads command, file or env is refused, and so is an applied one: edit it and runy apply it again.

get decrypts an encrypted secret and prints the value. ls lists the secrets in the workspace’s sources with their file, where the value comes from and their state. See runy secret for every flag.

set and rekey make the daemon read the resource files again, and warn when this machine’s key is not a recipient, since its daemon could not read the value.

  1. The new person or machine runs runy secret key and sends you the public key.
  2. Add it to recipients in .runy.json.
  3. On a machine that can already read the values, run runy secret rekey. It decrypts every encrypted secret in the workspace’s sources (or the --source folders) first and writes nothing when one does not decrypt, listing those. Then it writes each one encrypted to the current recipients.
  4. Commit the changed files. The new machine reads the secrets once it has them.
  1. Delete the entry from recipients.
  2. Run runy secret rekey, so the files are encrypted to the remaining recipients.
  3. Rotate the values the person could read: set a new token at its provider, then runy secret set it.

The rekey is not enough on its own. Removing a recipient does not revoke what they already read, since they may have kept a copy of the value or of the old file.

secrets.key in the state folder is the only copy of this machine’s private key. Without it the machine can no longer decrypt the values encrypted to it. Back it up where you keep your other keys, or add a second recipient that you hold elsewhere.

secrets.revision next to it is a random key that the daemon uses for the placeholders’ revisions. It decrypts nothing. Keeping it means the same value renders the same placeholder after a restart or an upgrade, so processes that read the secret are not restarted for nothing. Losing it restarts them once.

A secret whose value this machine’s key cannot read is in Error with:

not a recipient: add `age1...` to the workspace's recipients and run `runy secret rekey` where the value can be read

The message names this machine’s public key. Send it to someone whose machine can read the value, have them add it to recipients and run runy secret rekey, then pull the changed files. If nobody can read the value any more, set it again with runy secret set from its provider.