The fastsecrets guide
One store, many machines. Each secret lives in an age-encrypted file (age is a small, widely used open-source file encryption tool) in a git repository you own. Each machine holds its own key (inside the Secure Enclave on a Mac) and decrypts only the scopes it was encrypted to. get and run are a single native call with no daemon and no plaintext cache of their own.
Install
Pick one. All three install fastsecrets with its helper scripts next to it (install.sh tells you when its bin folder is not on your PATH yet).
curl -fsSL https://raw.githubusercontent.com/abe238/fastsecrets/main/install.sh | shPrebuilt for macOS and Linux, arm64 and x86_64. Checks the sha256. Never uses sudo.
brew install abe238/tap/fastsecretsmacOS and Linux.
cargo install fastsecrets && fastsecrets setup-libexecFrom source. Run setup-libexec again after every upgrade.
install.shinstalls into~/.local. Use--prefix DIRto change it and--version vX.Y.Zto pin one.- The prebuilt macOS binaries need macOS 14 or newer. On an older Mac, build from source.
- After
cargo install,fastsecrets setup-libexecwrites the helper scripts (built into the binary) to~/.cargo/libexec/fastsecrets. Run it again after everycargo installupgrade. - The write side needs age 1.3 or newer and git. On a Mac:
brew install age age-plugin-se(age-plugin-se gives you a Secure Enclave key). On Linux: git and age 1.3 or newer. Many distributions still package an older age; the age releases have static binaries.getandrunneed neither.
Create a store
fastsecrets initinit creates ~/.config/fastsecrets (a git repository), a key at ~/.config/age/key.txt (a Secure Enclave key on a Mac with age-plugin-se, else a plain age key file, mode 600), the recipients list for the all scope, and a first commit. It never touches an existing store: run again, it reports there is nothing to do. init --file makes a software key file instead of a Secure Enclave key.
Nothing is copied into the Mac login keychain unless you opt in with SECRETS_BACKEND=keychain; then writes also copy values into it, as a cache for other programs. See Sync and the security model.
Add a secret
fastsecrets set OPENAI_API_KEYset prompts for the value twice (hidden) and never takes it as an argument, because arguments are visible in ps and end up in shell history and transcripts. Run it in your own terminal, never in an agent's chat. Piping works:
printf '%s' "$TOKEN" | fastsecrets set NAME--ttl 2h(s m h d w, for example1h30m) stops it being served after the limit on every machine.--scope Spicks the scope (defaultall).- Each write is checked and committed, and pushed when there is a remote. A write that cannot be committed or pushed is undone on this machine.
Research footnote
Each write validates first, re-encrypts, proves the result decrypts back, commits, pushes when there is a remote, and refreshes this machine. Only one write runs at a time (a kernel file lock). A machine whose remote is read-only refuses writes up front.
Use a secret: run
run puts values into a program's environment and prints nothing. This is the way an agent should use a secret.
fastsecrets run OPENAI_API_KEY -- python app.py
fastsecrets run --mask OPENAI_API_KEY -- python app.py
fastsecrets run --mask GH_TOKEN=GITHUB_TOKEN -- gh api user # another variable name
fastsecrets run --mask P=login:example.com U=login:example.com:username -- ./post.sh # a website login- SPEC is
NAME,VAR=NAME, orVAR=login:SITE[:FIELD](FIELD: password, username, url, note). - All or nothing. A missing, empty, expired or ambiguous secret exits 1 and prints nothing; the program is not started with half of what it asked for.
- One
runper step, every name in it. A read that asks for five names costs one decrypt per scope file, the same as one name. Separate calls cost separate process starts and, with a Secure Enclave key, separate chip operations that queue behind each other. - Without
--mask,runbecomes the program itself, so no process holding the values stays behind. --maskreplaces any secret value the program prints with[secret:NAME], and fastsecrets stays alive as a filter on the program's output. It turns on by itself in a shell that sets a known agent variable (CLAUDECODE,CODEX_THREAD_ID,GEMINI_CLI,CURSOR_AGENT,OPENCODE,AI_AGENT, ...) orSECRETS_AGENT=1; pass it anyway. It guards against an accidental echo of an exact value only: an encoded form (base64, URL-encoded) gets through.--fd N NAMEhands a value on file descriptor N instead of the environment.- A website login spec moves the whole call to the bash side, which is slower and reads each value separately. Keep login specs out of a hot path.
- Exit codes:
runexits with the program's status (126 when it cannot be executed, 127 when it is not found).
Read a secret: get
get prints values, so it is for scripts. Never run a bare get where an agent reads the output.
v="$(fastsecrets get NAME)" # one name: the bare value
fastsecrets get A B C # NAME=value lines, all or nothing
fastsecrets get NAME --copy # to the clipboard, cleared after 30 sExit codes: 0 success, 1 failure (missing, expired, refused), 2 usage error.
Research footnote
get and run are answered by the binary; get --copy and a run with a website login go to the bash scripts in <prefix>/libexec/fastsecrets/, found next to the binary itself and never on PATH.
List, change, delete
fastsecrets list [--scope S] # names and scopes, never values
fastsecrets rm NAME [--scope S] # delete
fastsecrets edit [--reencrypt] [--logins] [S] # edit a whole scope in $EDITOR (people only)
fastsecrets purge # drop secrets past their time limit
fastsecrets log [NAME] # access log, names only
fastsecrets login set|get|list|rm # website loginsDeleting is not revoking: rotate the secret at its source too. Old versions stay in git history.
Website logins: fastsecrets login set example.com --user NAME prompts for the password.
Scopes
A scope is a recipients list. store/<scope>.env.age is encrypted only to the public keys in recipients/<scope>.txt, so a machine outside that list cannot read it even while holding the file. The boundary is cryptography.
initmakesall. Make more by writingrecipients/<scope>.txtandfastsecrets set NAME --scope <scope>.- A name lives in one scope only.
- Website logins default to a scope named
macwhen the store has one (a scope kept to your desktops), else toallwhileallreaches only this machine (a recovery key aside). Whenallis shared with other machines,login setasks for--scope, so a website password never lands on a server by default.
More machines
Give the store a private git remote:
git -C ~/.config/fastsecrets remote add origin URL && git -C ~/.config/fastsecrets push -u origin HEADEnroll a new machine
A private key is never copied between machines.
# on the new machine: install fastsecrets and age, then
git clone <your store remote> ~/.config/fastsecrets
fastsecrets key new # prints this machine's public key
# on a machine that can push: add a "# name" line and the key to recipients/<scope>.txt
fastsecrets edit --reencrypt <scope> # required: the list does nothing until re-encrypted
# back on the new machine
fastsecrets load && fastsecrets sync install && fastsecrets verifyA server can pull with a read-only deploy key; it can then read but never rewrite the store.
Remove a machine
Delete its lines from recipients/*.txt and run fastsecrets edit --reencrypt <scope> for each scope. It already read the current values, and git history keeps every old ciphertext, so rotate the secrets at their source too.
Secure Enclave or software key
| Secure Enclave (Mac with age-plugin-se) | Software key (Linux, or --file) | |
|---|---|---|
Key file at ~/.config/age/key.txt | a handle only this Mac's chip can use | the whole private key, mode 600 |
| A copy of the key file (backup, synced folder, stolen disk image) | decrypts nothing anywhere else | decrypts every scope it is a recipient of |
| Per-use prompt | none (--access-control none, so jobs and agents work unattended) | none |
| Survives a new logic board or a new Mac | no: that is what the recovery key is for | yes, if you copy the file |
| Public key | age1tag1..., which age 1.3+ encrypts to with no plugin | age1... |
fastsecrets key shows this machine's key and its kind; fastsecrets key new [--file] makes one (init does this for you). The Secure Enclave protects against the key being copied, not against a process on this Mac using it. Only with the opt-in keychain backend does the login keychain hold copies of the values.
Speed: in the benchmark on the M5, a software key reads one secret in 3.24 ms and a Secure Enclave key in 9.05 ms. All results.
Research footnote
About 4.5 ms of every chip read is the Secure Enclave itself. Both numbers are medians of session medians for the get1 row, Apple M5 Pro.
Sync
fastsecrets sync install # run load every hour
fastsecrets sync status
fastsecrets sync remove
fastsecrets load # pull and verifysync install runs fastsecrets load every hour: a LaunchAgent labeled com.fastsecrets.sync on macOS, a cron line tagged # fastsecrets-sync on Linux. With the opt-in keychain backend on a Mac, load also fills the login keychain as a cache for other programs, and prunes what the store no longer defines. fastsecrets verify reports a sync that stopped.
The Mac keychain cache is off by default. To opt in, set SECRETS_BACKEND=keychain on your fastsecrets calls. To keep it on for the sync job, add the variable to the LaunchAgent's EnvironmentVariables yourself: sync install does not carry it into the job.
Keychain
fastsecrets keeps no keychain copy unless you opt in. get and run read the encrypted store.
The opt-in, on a Mac: with SECRETS_BACKEND=keychain, every write (set, rm, edit) and every load or hourly sync copies each value of the scopes this Mac reads into the login keychain, for programs that read secrets from the keychain. load also prunes what the store no longer defines.
- The native
getandrunnever read the copy. Only the bash side does:get --copyand arunwith a website login. When the login keychain is locked in the session (over SSH, for example), they read the store with this machine's key instead. - The copies are guarded by the login keychain, not by the Secure Enclave key. They are written as items any app can read (
-A). - It is a second copy of every secret, refreshed by writes and
load.
Why we leave it off, with the numbers: Why not the Keychain?
Verify
fastsecrets verify [--offline]Checks that this machine's copy is sound and current: recipients against ciphertext, and a sync that stopped. Run it when a secret looks stale or missing, and read its problem: lines.
Recovery key
fastsecrets recovery initIn your own terminal, recovery init makes one extra key, locked with a passphrase, adds it to every scope, and re-encrypts. Move the file off your machines. fastsecrets recovery test FILE proves it still opens every scope. With only the file, the passphrase and a copy of the store, plain age reads it, without fastsecrets:
age -d -i fastsecrets-recovery-key.age store/all.env.ageA Secure Enclave key does not survive a new logic board or a new Mac. That is what the recovery key is for.
Environment variables
| Variable | Default | What |
|---|---|---|
SECRETS_DIR | ~/.config/fastsecrets | the store (a git repository) |
AGE_KEY | ~/.config/age/key.txt | this machine's key |
SECRETS_STATE_DIR | ${XDG_STATE_HOME:- | access log, sync log, index |
SECRETS_BACKEND | age | bash side: age reads the store; keychain (macOS opt-in) also keeps a login-keychain copy |
SECRETS_AGENT | unset | 1: treat this shell as an agent's (masking on, editors refused) |
SECRETS_ALLOW_KEYCHAIN | unset | 1: let load fill the login keychain from a store outside the default path |
SECRETS_KEYCHAIN | login keychain | a keychain file for the cache (tests) |
SECRETS_LOCK_WAIT | 120 | seconds a write waits for another write to finish |
SECRETS_COPY_SECONDS | 30 | how long --copy leaves a value on the clipboard |
SECRETS_FAST_AGE | unset | absolute path of an age binary for key types the reader cannot use natively |
SECRETS_FAST_TRACE | unset | 1: phase timings on stderr (names and times only) |
EDITOR | vi | for edit |
An empty value counts as unset.
All commands
fastsecrets init [--scope S] [--file] create a store and this machine's key
fastsecrets run [--mask] [--fd N NAME] SPEC... -- COMMAND
COMMAND with secrets in its environment
fastsecrets get NAME [NAME...] print values (one name: the bare value)
fastsecrets get NAME --copy to the clipboard, cleared after 30 s
fastsecrets list [--scope S] names and scopes, never values
fastsecrets set NAME [--scope S] [--ttl 2h] create or replace (prompts, or stdin)
fastsecrets rm NAME [--scope S] delete
fastsecrets edit [--reencrypt] [--logins] [S] edit a whole scope in $EDITOR (people only)
fastsecrets purge drop secrets past their time limit
fastsecrets login set|get|list|rm website logins
fastsecrets load [--no-pull] [--render PATH] pull and verify; with SECRETS_BACKEND=keychain fill the login keychain
fastsecrets sync install|remove|status|run run load every hour (LaunchAgent or cron)
fastsecrets verify [--offline] is this machine's copy sound and current?
fastsecrets key [new [--file]] this machine's key
fastsecrets recovery init|test an offline, passphrase-locked recovery key
fastsecrets export FILE.xlsx|.csv [--logins] everything in plain text (people only)
fastsecrets log [NAME] access log, names only
fastsecrets help [COMMAND] | version | setup-libexecTroubleshooting
| Message | Meaning | Do |
|---|---|---|
not found | no secret of that name on this machine | check fastsecrets list; store it with fastsecrets set NAME |
expired at ... | it was stored with a time limit | set it again if still needed |
more than one readable scope | the name exists twice | remove one with fastsecrets rm NAME --scope S |
cannot push to the store's remote | this machine has read-only access | make the change on a machine that can push |
decrypts none of the scope(s) | this machine's key is not a recipient | see Enroll a new machine |
helper scripts, which are not installed | a cargo install without the bash side | run fastsecrets setup-libexec |
no age identity | no key on this machine yet | first machine: fastsecrets init; a machine joining an existing store: Enroll a new machine, not init |
- A secret looks stale or missing: run
fastsecrets verifyand read itsproblem:lines. - The output shows
[secret:NAME]: the program echoed a secret value and--maskhid it. - A key type the reader cannot use natively (for example a post-quantum Secure Enclave key, an ssh key or a passphrase file): nothing is read, the call exits 1, and the message names
SECRETS_FAST_AGE, which takes the absolute path of anagebinary to hand those reads to. - Where a read spent its time:
SECRETS_FAST_TRACE=1prints phase timings on stderr (names and times only).
Uninstall
fastsecrets has no uninstall command. These steps remove what this guide says it creates.
- Stop the hourly sync:
fastsecrets sync remove. - Keep a way back in, or decide you do not need one. Your secrets are in the store, encrypted to this machine's key. A Secure Enclave key cannot be copied: once it is gone, only a recovery key or another enrolled machine opens the store. If other machines use the store, remove this machine first (see Remove a machine).
- Remove the program. Homebrew:
brew uninstall fastsecrets. Cargo:cargo uninstall fastsecrets, then delete~/.cargo/libexec/fastsecrets.install.sh: delete~/.local/bin/fastsecretsand~/.local/libexec/fastsecrets(or the same two under the--prefixyou chose). - Remove the data you no longer want: the store at
~/.config/fastsecrets(and its git remote), the key at~/.config/age/key.txt, and the state folder at~/.local/state/fastsecrets(access log, sync log, index). These are the defaults;SECRETS_DIR,AGE_KEYandSECRETS_STATE_DIRmove them. - On a Mac, check the login keychain, if you opted in. Only with
SECRETS_BACKEND=keychaindid writes andloadcopy values into it. Deleting the store folder does not remove those copies. Look for your secret names in Keychain Access.
Limits
- Single-line values only (base64 a PEM key first). Names:
A-Z a-z 0-9 _, not starting with a digit. - A scope cannot be emptied by an edit: a scope with nothing in it is far more often a truncated edit than an intention.
- Not post-quantum by default. age and the Secure Enclave plugin offer post-quantum keys, but age will not mix them with classic ones, so every machine and the recovery key would have to move together. The reader reads post-quantum software keys.
- The bash side is bash 3.2 compatible (macOS
/bin/bash).