Skip to main content

Secrets and Settings (fnox)

Every setting and secret this project deploys is declared in one committed file, fnox.toml at the repository root, read by fnox (by jdx, MIT). Each place that reads settings has a profile of its own: local development, the self-hosted machine and the repository's Actions secrets. Secrets are stored in the file encrypted with age for a short list of public keys; development values are plain text. make targets copy each profile to its place, a value only ever passing through a pipe, and make secrets-doctor compares the names on every place. The decision and the alternatives are ADR 0021, which supersedes ADR 0016.


Profiles​

ProfileHoldsCopied to
devPlain, public values that start the stack on a laptop: the development INTERNAL_SECRET and JWT_SECRET (the API refuses both when APP_ENV=production), a dashboard login (dev), the compose postgres. No key is needed.Nothing: make dev runs under fnox -P dev exec, make env writes .env for docker compose, and your shell can use it with fnox activate and FNOX_PROFILE=dev
selfhostThe settings of /etc/ghb/selfhost.env on the self-hosted machine (deploy/selfhost) that are not its topology: an encrypted backup of the secrets install.sh generates, the values from outside services (GitHub OAuth, Razorpay and the invoice details, the dead-man URL, OpenRouter, the dump bucket) and the choices with their defaults./etc/ghb/selfhost.env, with make secrets-push-selfhost (sudo ghb import). The machine's file is the live copy.
githubCLAUDE_CODE_OAUTH_TOKEN (or ANTHROPIC_API_KEY, billed per token, left empty while the token is set), DESIGN_SYSTEM_BOT_TOKEN, SKILLS_SYNC_TOKEN, DOCKERHUB_USERNAME, DOCKERHUB_TOKENThe repository's Actions secrets, with make secrets-push-github

There are no top-level secrets: every profile would inherit them, and a development value must never reach the production machine. Every key has a description (fnox -P <profile> list shows them) and either a plain default or if_missing = "ignore", so make secrets-check passes before any value is stored.

tests/test_fnox_config.py keeps each profile equal to what reads it:

  • selfhost: every ${KEY} in deploy/selfhost/compose*.yaml and every setting ghb and install.sh read or write is either in the profile or install-owned, and the profile holds nothing they ignore. It holds no e-mail setting: the product sends no e-mail.
  • github: only secrets a workflow reads.
  • scripts/secrets-sync.sh: its lists of generated and install-owned keys match install.sh.
  • Makefile: FNOX_PROFILES, the profiles make secrets-check runs fnox check on, lists every profile.

Install-owned keys are the topology install.sh writes from its flags: the mode, the host names and URLs, the image source, POSTGRES_PASSWORD, the owner, IMAGE_TAG, GHB_MONITORING, GHB_BACKUP_DIR, CLOUDFLARE_TUNNEL_TOKEN and CHAT_USERNAME (ghb's INSTALL_KEYS are among them). They stay out of fnox.toml: they describe one machine, and a new install writes them again.

Setup day​

The path for a new self-hosted machine. The targets run on that machine, which holds the age key (~/.config/fnox/age.txt) and the checkout.

  1. Install. sudo ./deploy/selfhost/install.sh --domain <your domain> --github-user <your GitHub login> (modes and flags). It writes the topology and generates every internal secret.

  2. Back up the generated secrets. make secrets-capture-selfhost reads /etc/ghb/selfhost.env with sudo and stores the secrets install.sh generated in the selfhost profile, age-encrypted. Commit fnox.toml: it holds only ciphertext, and the two encryption keys now survive a dead disk.

  3. Store the outside values. For each feature you want, fnox -P selfhost set KEY (it asks without echo) or ... | fnox -P selfhost set KEY (from stdin):

    • GitHub sign-in: GITHUB_OAUTH_CLIENT_ID, GITHUB_OAUTH_CLIENT_SECRET
    • payments: RAZORPAY_KEY_ID, RAZORPAY_KEY_SECRET, RAZORPAY_WEBHOOK_SECRET with BILLING_SELLER_NAME and BILLING_SELLER_ADDRESS (all of them, or none)
    • the dead-man alert: DEADMAN_PING_URL
    • the assistant's server keys: OPENROUTER_API_KEY
    • copies of the dumps: every BACKUP_S3_* setting with BACKUP_AGE_RECIPIENTS

    Then fnox -P github set DESIGN_SYSTEM_BOT_TOKEN (and the other Actions secrets). Check with make secrets-check and commit.

  4. Push. make secrets-push-selfhost (one restart), then make secrets-push-github.

  5. Verify. make secrets-doctor, then sudo ghb status. The doctor should report no differences, with one known exception: the repository variable CI_RUNNER, which no workflow reads; remove it once by hand (gh variable delete CI_RUNNER).

On a machine that replaces a lost one, run make secrets-push-selfhost before step 1: install.sh generates only the secrets that are still missing, so the machine keeps the encryption keys and service credentials it had, and a restored dump stays readable. If install.sh ran first, it generated new keys, and step 2 refuses to store them over fnox's: run make secrets-push-selfhost ARGS=--replace-encryption-keys instead, before restoring a dump and before the new machine stores anything with its own keys. ghb is not in the PATH until install.sh links it, so the target then imports with the checkout's deploy/selfhost/ghb, after the same checks: it stops before importing anything when fnox could not decrypt a value, which would otherwise leave the encryption keys out and let install.sh generate new ones.

Until the tooling runs​

On a machine without fnox, or without the age key at hand, change one feature at a time with ghb set, typing the secret so it stays out of the shell's history (it is still visible in ps while ghb set runs):

read -rs v && sudo ghb set "GITHUB_OAUTH_CLIENT_SECRET=$v"; unset v

Once, copy /etc/ghb/selfhost.env off the machine, encrypted (for example sudo cat /etc/ghb/selfhost.env | age -r <your age public key> >selfhost.env.age), because both encryption keys exist nowhere else. When fnox is back, make secrets-capture-selfhost stores the generated secrets and fnox -P selfhost set KEY the values you set by hand.

The sync targets​

scripts/secrets-sync.sh does the work; the targets name its subcommands. A value never appears as a command-line argument (other users see those in ps), in a file or in the output: it goes from fnox to the receiving command through a pipe, and the output names keys only. The script reads the committed fnox.toml alone (fnox -c <path>), so a personal override in fnox.local.toml is never pushed, and push-selfhost stops when the export holds a name the profile does not declare.

TargetWhat it does
make secrets-capture-selfhostStores the secrets install.sh generated in /etc/ghb/selfhost.env in the selfhost profile (fnox import ... -p age), leaving out empty ones. Other settings in the file are not touched. It stores nothing when the machine's CREDENTIALS_ENCRYPTION_KEY or NOTIFY_ENCRYPTION_KEY list leaves out a key fnox's list holds (ghb import's check, the other way round), since fnox's copy may be the only one a restored dump can be read with; it decrypts fnox's list for that, and skips an empty slot. ARGS=--replace-encryption-keys stores the machine's list anyway.
make secrets-push-selfhostPipes the selfhost profile's JSON export to sudo ghb import, which takes only names the stack reads and restarts once. It stops before the import when fnox could not decrypt a value or left out a stored key (fnox exits 0 in both cases). ARGS=--no-restart skips the restart; ARGS=--replace-encryption-keys lets fnox's encryption keys replace the machine's (see Rotating). Before install.sh has linked ghb, it runs the checkout's deploy/selfhost/ghb.
make secrets-push-githubSets each stored key of the github profile as an Actions secret, one gh secret set at a time with the value on stdin.
make secrets-doctorCompares names, never values: the profiles in fnox.toml (parsed with Python's tomllib, nothing decrypted), what deploy/selfhost reads, the machine (sudo ghb keys) and the repository's secrets and variables (gh secret list, gh variable list). It reports what is missing on a place, what a place has that fnox does not declare or declares without a value (right after install.sh, the generated secrets until make secrets-capture-selfhost stores them), and what nothing reads, and exits 1 when it finds any. A place whose tool is missing, not signed in or failing (ghb keys or ghb keys --known, for example) is reported as skipped and named again at the end; with no difference but a skipped place it exits 2, because nothing was compared there.

The push targets copy only keys that hold a value in fnox.toml; an empty one is skipped, never sent as a blank. They need fnox, Python 3.11 or later, and gh signed in for push-github; push-selfhost and capture-selfhost need sudo on the self-hosted machine, whose ghb needs bash 4.4.

Install fnox​

Version 1.43.0. With mise: mise use -g fnox@1.43.0. Without it, take the musl build for your machine from the release, check its SHA-256 against the digest GitHub shows next to the file, and put fnox on your PATH:

FileSHA-256
fnox-x86_64-unknown-linux-musl.tar.gz3d221a6439957f3e425410a4614a45ec02b278e9c20d5838eb7d6d3b3748ac19
fnox-aarch64-unknown-linux-musl.tar.gze84f1eadc00ee0ec3a19e31ab5e149e597bf3ad2f88647b1b28a3b7801d2f927
curl -fsSLO https://github.com/jdx/fnox/releases/download/v1.43.0/fnox-x86_64-unknown-linux-musl.tar.gz
echo "3d221a6439957f3e425410a4614a45ec02b278e9c20d5838eb7d6d3b3748ac19 fnox-x86_64-unknown-linux-musl.tar.gz" | sha256sum -c -
tar -xzf fnox-x86_64-unknown-linux-musl.tar.gz fnox && install -m 0755 fnox ~/.local/bin/fnox

Without fnox, nothing changes for development: make dev and the services read their .env files, made from the .env.example files.

Who can decrypt​

[providers.age] recipients in fnox.toml lists the public keys every encrypted value is written for. Each holder keeps the private half:

RecipientPrivate keyStatus
owner~/.config/fnox/age.txt on the owner's machine (mode 0600), where fnox looks by defaultlisted
cithe GitHub secret FNOX_AGE_KEYcommented slot: add it only when a workflow needs a profile's secrets; none does today

A profile is not an access boundary: anyone holding a listed key can read every encrypted value of every profile.

Everyday use​

make dev # the API, the Observatory and the dashboard on the dev profile
make env && docker compose up --build -d # compose reads .env; make env refuses to replace a .env it did not write
make secrets # fnox edit: the file in $EDITOR with every value decrypted
make secrets-check # the key test, then fnox check on every profile

fnox -P selfhost set GITHUB_OAUTH_CLIENT_SECRET # asks without echo, stores ciphertext
fnox -P selfhost set SIGNUP_MODE --default open # a plain setting
fnox -P selfhost list # keys and descriptions, no values
make secrets-push-selfhost # copy the profile to the machine, one restart
make secrets-doctor # which names differ, on every place

make dev's processes reach postgres on 127.0.0.1 through DATABASE_URL, which is marked env = "exec": fnox exec passes it, while fnox export and the shell leave it out, so compose keeps its own address for the bundled postgres. Start that postgres first (docker compose up -d postgres).

Personal overrides go in fnox.local.toml next to fnox.toml (gitignored, and refused by the pre-commit hook), for example another development database for make dev:

[profiles.dev.secrets]
DATABASE_URL = { default = "postgresql://user:password@host/db?sslmode=require", env = "exec", description = "my development database" }

The development values are public, and compose publishes the dashboard, the API, the Observatory and the MCP server on every interface: on a network you do not trust, override INTERNAL_SECRET, JWT_SECRET and CHAT_PASSWORD the same way.

Commit fnox.toml after each change. The pre-commit hook refuses a value that is not age ciphertext, an exported production.env and fnox.local.toml, and runs tests/test_fnox_config.py (also when deploy/selfhost/compose*.yaml, ghb, install.sh or scripts/secrets-sync.sh change); a commit of fnox.toml alone runs no other suite.

Adding a key​

For the self-hosted machine:

  1. Pass it to the services that read it in deploy/selfhost/compose.yaml, and list it in the settings table of deploy/selfhost/README.md.
  2. Add it under [profiles.selfhost.secrets] with a description and either a plain default (compose's own default) or if_missing = "ignore". A secret gets no default: store its value with fnox -P selfhost set KEY.
  3. If local development needs it, add a plain default under [profiles.dev.secrets] and to the matching .env.example.
  4. make secrets-check, then make secrets-push-selfhost.

For the Actions secrets, add it under [profiles.github.secrets] with a description and if_missing = "ignore", store the value with fnox -P github set KEY, and push. The test refuses a name no workflow reads.

Adding a machine or CI​

  1. On that machine, make a key and print its public half:

    age-keygen -o ~/.config/fnox/age.txt # mode 0600
    age-keygen -y ~/.config/fnox/age.txt

    For CI, make the key on your own machine (age-keygen -o ci.key), store the whole AGE-SECRET-KEY-1... line as the secret FNOX_AGE_KEY of the GitHub environment production, then delete ci.key.

  2. Put the public key into recipients with a comment naming the machine.

  3. Re-encrypt with a key that is already listed, and commit: fnox reencrypt -p age -f once for each profile that holds ciphertext (-P selfhost, -P github, ...). The new holder can decrypt after the next pull.

A workflow that needs production values installs fnox as above and runs the command under fnox; nothing is written to disk:

- name: Run with the selfhost profile
env:
FNOX_AGE_KEY: ${{ secrets.FNOX_AGE_KEY }}
FNOX_NON_INTERACTIVE: "true"
run: |
fnox -P selfhost ci-redact # masks every value in the job's log
fnox -P selfhost exec -- ./the-command

fnox -P selfhost export -o <file> writes a file instead, for a tool that only reads files; run it under umask 077 and delete the file in the same step.

Rotating​

  • A value: store the new one with fnox -P <profile> set KEY, commit, and push it with the profile's target. What each secret's rotation affects, and the order for service credentials and the two encryption keys, is in 06 operations. A value changed on its place by hand (sudo ghb set, the GitHub settings) goes into fnox too, or the next push puts the old one back. The two encryption keys are the exception: ghb import refuses a list that leaves out a key the machine's list holds, so a push of an older fnox copy stops with the key's name instead of making stored rows unreadable.
  • A key: remove its recipient, re-encrypt each profile (fnox -P <profile> reencrypt -p age -f) and commit. Git history keeps the old ciphertext, which the removed key still opens: when a key leaves because it may have leaked, rotate every value it could read as well.

fnox export quotes a value that holds characters such as ?, , or =. Compose reads the quotes as quoting; kubectl create secret generic --from-env-file and gh secret set -f keep them, or misread a single quote, so build such input from fnox export -f json or one fnox get at a time, as the sync script does.

If the owner's key is lost​

Keep an offline copy of ~/.config/fnox/age.txt (a password manager, or on paper in a safe place), never in the repository or an unencrypted cloud folder. Without it:

  1. Make a new key (age-keygen -o ~/.config/fnox/age.txt) and put its public half into recipients in place of the lost one.
  2. If another listed key survives, re-encrypt with it on its machine: FNOX_AGE_KEY_FILE=<that key> fnox -P <profile> reencrypt -p age -f for each profile, and commit.
  3. If the self-hosted machine still runs, its /etc/ghb/selfhost.env holds every live value of the selfhost profile: make secrets-capture-selfhost stores the generated secrets again (encrypting needs no private key), fnox -P selfhost set KEY the others, and commit. The GitHub values cannot be read back: issue them again at their sources.
  4. Otherwise, issue new values at their sources (the GitHub App's client secret, Razorpay keys and webhook secret, the dump bucket's access key, the tokens of the github profile) and let install.sh generate the internal secrets on a new machine. A new CREDENTIALS_ENCRYPTION_KEY cannot read the OpenRouter keys users stored: they connect them again. A new NOTIFY_ENCRYPTION_KEY cannot open the alert channels' sealed URLs: they are created again.