ph) to expose data as template functions.
Overview
Passhole (ph) is a command-line interface for KeePass databases. Unlike KeePassXC CLI, Passhole provides a more streamlined interface for accessing KeePass databases from the terminal.
Setup
Install Passhole
Initialize Database
If you don’t have a KeePass database:Template Function
passhole
Retrieve a specific field from a KeePass entry:
passwordusernameurlnotes- Custom field names
Configuration
Basic Configuration
~/.config/chezmoi/chezmoi.toml
With Password Prompt
~/.config/chezmoi/chezmoi.toml
prompt = true, chezmoi will prompt for your database password once and cache it for the session.
Custom Arguments
~/.config/chezmoi/chezmoi.toml
Usage Examples
Basic Password Retrieval
~/.config/api-keys.env.tmpl
Git Configuration
~/.gitconfig.tmpl
Database Credentials
~/.config/db/config.yml.tmpl
AWS Credentials
~/.aws/credentials.tmpl
Multiple API Keys
~/.config/api-keys.env.tmpl
NPM Configuration
~/.npmrc.tmpl
SSH Configuration
~/.ssh/config.tmpl
Docker Registry
~/.docker/config.json.tmpl
Managing KeePass Database with Passhole
Adding Entries
Listing Entries
Viewing Entries
Editing Entries
Deleting Entries
Entry Organization
Organize entries in groups (folders):Custom Fields
Passhole supports custom fields beyond the standard username/password:Complete Examples
Multi-Service Configuration
~/.config/services.yml.tmpl
Application Environment
~/.config/app/.env.tmpl
Troubleshooting
Database Locked
If usingprompt = true, chezmoi will prompt for your password once per session.
If prompt = false, ensure your database is unlocked or use a key file.
Entry Not Found
List all entries to find the correct path:Command Not Found
Ensure Passhole is installed:Testing Templates
Test template functions:Field Not Found
View all fields for an entry:Best Practices
- Use groups: Organize entries in logical groups (Personal, Work, API)
- Consistent paths: Use a clear naming convention for entry paths
- Custom fields: Use custom fields for structured data
- Backup database: Keep encrypted backups of your KeePass database
- Strong master password: Use a strong password for your database
- Use prompt mode: Enable
prompt = truefor better security - Test access: Verify entries are accessible before templating
- Sync carefully: If syncing database, ensure it’s encrypted
See Also
- Passhole GitHub
- KeePass Website
- KeePassXC - Alternative KeePass CLI
- Template Functions Reference