{% raw %}
Secrets Management¶
Provider-agnostic secrets via dot secrets. Supports macOS Keychain, pass, and age-encrypted local storage.
Providers¶
Provider selection is controlled by .chezmoidata.toml:
[secrets.policy]
provider = "auto" # auto | macos-keychain | pass | plain-enc
auto_load = true
[secrets.buckets]
ai = ["GEMINI_API_KEY", "CLAUDE_API_KEY", "OPENAI_API_KEY"]
infra = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "GITHUB_TOKEN"]
auto resolves in this order:
macos-keychainon macOSpasswhen availableplain-encfallback (age-encrypted local store)
Commands¶
# Bootstrap age key for chezmoi encrypted files
dot secrets-init
# Optional: create encrypted secrets file for chezmoi
dot secrets-create
dot secrets edit
# Managed secret store
dot secrets set GEMINI_API_KEY
dot secrets get GEMINI_API_KEY --raw
dot secrets list
dot secrets provider
# Emit export lines for a bucket
dot secrets load ai
# Load into current shell session
eval "$(dot env load ai)"
Shell Auto-Load¶
When auto_load = true, shell startup can load configured buckets automatically via dot env load <bucket>.
Environment toggles:
DOTFILES_SECRETS_PROVIDERDOTFILES_SECRETS_AUTO_LOADDOTFILES_SECRETS_BUCKET_NAMES
Governance¶
A pre-commit hook runs:
It blocks staged commits when likely secret patterns are found. In strict mode it also blocks exact matches against managed secret values.
SSH Key Encryption¶
This creates a local encrypted file, which you can add to chezmoi with chezmoi add --encrypt if needed.
External Secrets Backends¶
Chezmoi natively supports external secret managers as template functions. Configure the backend in .chezmoidata.toml:
1Password¶
Requires the 1Password CLI (op).
Use in templates:
Bitwarden¶
Requires the Bitwarden CLI (bw).
Use in templates:
HashiCorp Vault¶
Requires the Vault CLI (vault).
Use in templates:
pass (Password Store)¶
Requires pass.
Use in templates:
See the chezmoi documentation for full details on each backend.
Security Notes¶
- Never commit
~/.config/chezmoi/key.txtto version control. - Avoid shell history exposure — use
dot secrets setwhich prompts securely. - Rotate credentials on a regular schedule.