Quick Start
Generate a key usingchezmoi age-keygen:
Configuration
Specify age encryption in your configuration file with at least one identity and one recipient:~/.config/chezmoi/chezmoi.toml
Multiple Keys
chezmoi supports multiple identities and recipients for scenarios where you need to decrypt files on multiple machines or share encrypted files with others:~/.config/chezmoi/chezmoi.toml
Symmetric Encryption
To use age’s symmetric encryption, specify a single identity and enable symmetric mode:~/.config/chezmoi/chezmoi.toml
Passphrase Encryption
To use age’s symmetric encryption with a passphrase, setage.passphrase to true:
~/.config/chezmoi/chezmoi.toml
- When running
chezmoi add --encrypt - When chezmoi needs to decrypt files (
apply,diff,status)
Usage Examples
Encrypting Files
Add an encrypted SSH key:Editing Encrypted Files
Edit an encrypted file (automatically decrypts and re-encrypts):Using Different Keys Per Machine
Encrypting Specific File Types
Built-in age Encryption
chezmoi has built-in support for age encryption which is automatically used if theage command is not found in $PATH.
The built-in age encryption does not support:
- Passphrases
- Symmetric encryption
- SSH keys
Why No Passphrase Support?
Passphrases are not supported in built-in mode because chezmoi needs to decrypt files regularly (e.g., duringchezmoi diff or chezmoi status), not just when running chezmoi apply. Prompting for a passphrase each time would quickly become tiresome.
Why No SSH Key Support?
The age documentation explicitly recommends not using SSH keys:When integrating age into a new system, it’s recommended that you only support X25519 keys, and not SSH keys. The latter are supported for manual encryption operations.
Sharing Encrypted Files
To share encrypted files with another user:- Get their public age key (recipient)
- Add their recipient to your config:
~/.config/chezmoi/chezmoi.toml
- Re-encrypt existing files:
Troubleshooting
”failed to decrypt” Error
Ensure your identity file exists and contains the correct private key:Permission Denied
Check that your identity file has restricted permissions:Multiple Recipients Not Working
Verify your config hasrecipients (plural), not recipient:
Best Practices
- Store keys securely: Keep your identity file outside your chezmoi source directory
- Use different keys per environment: Personal vs. work machines
- Backup your keys: Without them, encrypted files cannot be decrypted
- Test decryption: Verify you can decrypt before removing originals
- Use age over GPG: age is simpler and more modern for new setups