Password Manager Functions
chezmoi provides template functions to securely integrate with popular password managers. These functions allow you to retrieve secrets, credentials, and other sensitive data from your password manager without storing them in your dotfiles.General Concepts
Caching
Most password manager functions cache their results during template execution, so calling the same function multiple times with the same arguments will only invoke the password manager CLI once.Authentication
Password managers typically require authentication before accessing secrets. chezmoi will:- Use existing authenticated sessions when available
- Prompt for authentication interactively when needed
- Pass through environment variables for non-interactive authentication
Configuration
Each password manager can be configured in the chezmoi config file:~/.config/chezmoi/chezmoi.toml
1Password
Integrate with 1Password using the 1Password CLI.onepassword uuid [vault] [account]
Returns structured data from 1Password.
Accessing Fields
onepasswordDocument uuid [vault] [account]
Returns a document from 1Password.
onepasswordDetailsFields uuid [vault] [account]
Returns details fields from 1Password.
onepasswordItemFields uuid [vault] [account]
Returns item fields from 1Password.
onepasswordRead url
Reads a secret using 1Password secret reference URL.
Bitwarden
Integrate with Bitwarden using the Bitwarden CLI.bitwarden id
Returns structured data from Bitwarden.
bitwardenFields id
Returns custom fields from a Bitwarden item.
bitwardenAttachment id name
Returns an attachment from a Bitwarden item.
bitwardenAttachmentByRef reference name
Returns an attachment using a Bitwarden reference.
bitwardenSecrets key
Returns a secret from Bitwarden Secrets Manager.
LastPass
Integrate with LastPass using the LastPass CLI.lastpass id
Returns the password for a LastPass entry.
lastpassRaw id
Returns structured data from LastPass.
Pass (Password Store)
Integrate with pass, the standard Unix password manager.pass path
Returns the first line (password) from a pass entry.
passRaw path
Returns the entire contents of a pass entry.
passFields path
Returns structured data from a pass entry.
Configuration
~/.config/chezmoi/chezmoi.toml
Gopass
Integrate with gopass, a pass-compatible password manager.gopass path
Returns the first line from a gopass entry.
gopassRaw path
Returns the entire contents of a gopass entry.
KeePassXC
Integrate with KeePassXC using the CLI.keepassxc entry
Returns the password for a KeePassXC entry.
keepassxcAttribute entry attribute
Returns a specific attribute from a KeePassXC entry.
keepassxcAttachment entry attachment
Returns an attachment from a KeePassXC entry.
Keeper
Integrate with Keeper Security using the CLI.keeper path
Returns the password from a Keeper record.
keeperDataFields path
Returns structured data fields from a Keeper record.
keeperFindPassword path
Finds and returns a password from Keeper.
Dashlane
Integrate with Dashlane using the CLI.dashlanePassword title
Returns the password for a Dashlane entry.
dashlaneNote title
Returns the contents of a Dashlane secure note.
AWS Secrets Manager
Integrate with AWS Secrets Manager.awsSecretsManager secret-id
Returns and parses a secret from AWS Secrets Manager as JSON.
awsSecretsManagerRaw secret-id
Returns the raw secret string from AWS Secrets Manager.
Azure Key Vault
Integrate with Azure Key Vault.azureKeyVault secret-name
Returns a secret from Azure Key Vault.
Doppler
Integrate with Doppler secrets management.doppler project config secret
Returns a secret from Doppler.
dopplerProjectJson project config
Returns all secrets from a Doppler project as JSON.
Hashicorp Vault
Integrate with Hashicorp Vault.vault path
Returns structured data from Vault.
Keyring
Integrate with system keyrings (macOS Keychain, Windows Credential Manager, Linux Secret Service).keyring service account
Returns a password from the system keyring.
Generic Secret
Integrate with generic external secret commands.secret args…
Executes a configured secret command and returns the output.
secretJSON args…
Executes a configured secret command and parses the output as JSON.
Configuration
~/.config/chezmoi/chezmoi.toml
Practical Examples
Git Configuration with 1Password
dot_gitconfig.tmpl
SSH Configuration with Bitwarden
private_dot_ssh_config.tmpl
API Keys from Pass
dot_env.tmpl
Multi-Provider Strategy
dot_config_app_credentials.toml.tmpl
Conditional Secret Retrieval
run_once_install-creds.sh.tmpl
Security Best Practices
- Never commit secrets: Template files should only contain function calls, not actual secrets
- Use encryption: Enable encryption for the chezmoi source directory if needed
- Audit access: Regularly review which secrets are being accessed
- Rotate credentials: Use password manager features to rotate credentials regularly
- Limit scope: Only retrieve secrets that are actually needed
- Use secret references: Prefer secret references (like 1Password’s
op://) when supported
Troubleshooting
Authentication Issues
Testing Secret Retrieval
Debugging
Related Pages
- Template Functions - All template functions
- Template Variables - Built-in variables
- Configuration File - Password manager configuration
- Encryption - Encrypting secrets in the source directory