chezmoi edit.
Quick Start
Configure GPG encryption in your chezmoi config:~/.config/chezmoi/chezmoi.toml
Asymmetric (Private/Public Key) Encryption
Asymmetric encryption uses your GPG key pair. Specify the encryption key recipient in your configuration:~/.config/chezmoi/chezmoi.toml
~/.config/chezmoi/chezmoi.toml
How It Works
chezmoi will encrypt files using:Symmetric Encryption
For symmetric encryption (password-based), configure:~/.config/chezmoi/chezmoi.toml
Encrypting with a Passphrase
If you want to encrypt files with a passphrase that’s stored in plaintext on your machines:~/.local/share/chezmoi/.chezmoi.toml.tmpl
- Prompt for the passphrase on first run of
chezmoi init - Remember the passphrase in your configuration file
- Use it automatically for encryption/decryption
Usage Examples
Encrypting Files
Add an encrypted SSH key:Editing Encrypted Files
Edit an encrypted file (automatically decrypts and re-encrypts):Different Recipients Per Machine
Encrypting Specific File Types
Muting GPG Output
GPG sends some info messages to stderr instead of stdout. To mute this output, add--quiet to gpg.args:
~/.config/chezmoi/chezmoi.toml
Custom GPG Arguments
You can pass additional arguments to GPG:~/.config/chezmoi/chezmoi.toml
Using a Specific GPG Key
If you have multiple GPG keys, specify which one to use:~/.config/chezmoi/chezmoi.toml
Multiple Recipients
To encrypt files for multiple recipients:~/.config/chezmoi/chezmoi.toml
Setting Up GPG Keys
If you don’t have a GPG key yet:Generate a New Key
List Your Keys
Export Your Public Key
Import a Key on Another Machine
Troubleshooting
”no public key” Error
Ensure the recipient key is in your GPG keyring:“decryption failed” Error
Verify you have the private key:Trust Issues
If GPG complains about untrusted keys:--trust-model always in your config:
Permission Denied
Check GPG directory permissions:Best Practices
- Backup your keys: Export and securely store your GPG keys
- Use subkeys: Create separate subkeys for encryption
- Set expiration: Use key expiration dates for better security
- Test decryption: Verify you can decrypt before removing originals
- Consider age: For new setups, age is simpler and more modern
GPG vs age
| Feature | GPG | age |
|---|---|---|
| Maturity | Very mature, widely used | Modern, actively developed |
| Key Management | Complex, multiple key types | Simple, single key type |
| Setup | Requires GPG installation | Built-in to chezmoi |
| Speed | Slower | Faster |
| Best For | Existing GPG users | New users, simple setups |