Key Management
Keys are discovered in this priority order:
DOTENVAGE_AGE_KEYenv var (full identity string)AGE_KEYenv var (full identity string)EKG_AGE_KEYenv var (for EKG project compatibility)- OS user keychain (via the
keyring crate):
- macOS: Login Keychain
- Linux: kernel keyutils (no D-Bus required)
- Windows: Credential Manager
- System-level store (for daemon processes):
- macOS: System Keychain first, then file fallback at
/etc/dotenvage/<key-name>.key - Linux:
/etc/dotenvage/<key-name>.key - Windows:
%ProgramData%\dotenvage\<key-name>.key
- macOS: System Keychain first, then file fallback at
AGE_KEY_NAMEfrom .env → key file at$XDG_STATE_HOME/{AGE_KEY_NAME}.key- Default:
~/.local/state/{CARGO_PKG_NAME}/dotenvage.key
Use dotenvage keygen --store <target> to control where new
keys are stored:
# User key file (default)
dotenvage keygen --store file
# OS user keychain
dotenvage keygen --store os
# Both user keychain and file
dotenvage keygen --store both
# System-level store (for daemons, requires sudo/admin)
sudo dotenvage keygen --store system
Daemon key management
For system daemons (launchd daemons, systemd system services, Windows services) that start at boot without a user session, store the key in the system-level store:
# Store existing key in system-level store
sudo dotenvage keygen --store system
The daemon then discovers the key automatically via step 5 in the discovery chain — no environment variable embedding needed.
Custom system store directory
Set DOTENVAGE_SYSTEM_STORE_DIR when the file-based system store
should live outside the platform default location.
# Example: co-locate the dotenvage system key with your daemon config
DOTENVAGE_SYSTEM_STORE_DIR=/etc/myapp
When this variable is set, dotenvage loads and writes the system store key at:
- Unix:
$DOTENVAGE_SYSTEM_STORE_DIR/<key-name>.key - Windows:
%DOTENVAGE_SYSTEM_STORE_DIR%\<key-name>.key
This is useful for service deployments that keep all persistent state under an application-specific directory instead of the shared default.
You can place DOTENVAGE_SYSTEM_STORE_DIR in .env or
.env.local. dotenvage resolves it before key loading, just like
AGE_KEY_NAME.
macOS daemon fallback behavior
On macOS, dotenvage now checks the System Keychain first for system-level keys. If the key is not present there, it falls back to the file-based system store.
This supports launchd daemons and other non-interactive processes that may not have permission to read from the System Keychain but can still access a root-managed key file.
Project-Specific Keys
For multi-project setups, configure in .env:
# .env (committed, not secret)
AGE_KEY_NAME=myproject/myapp
Key stored at: ~/.local/state/myproject/myapp.key
XDG Base Directories
- Prefers
$XDG_STATE_HOME - Falls back to
~/.local/state - Or
$XDG_CONFIG_HOME/~/.config(legacy)
CI/CD
Set DOTENVAGE_AGE_KEY, AGE_KEY, or EKG_AGE_KEY in CI secrets:
env:
DOTENVAGE_AGE_KEY: ${{ secrets.AGE_KEY }}