GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
passhole() passhole()

ph [OPTIONAL ARGS] [COMMAND] [COMMAND OPTIONS] [COMMAND ARGS]

Show the contents of an entry, where PATH is the full path to the entry. The password field is spoilered and must be highlighted to reveal the plaintext password. Use --field FIELD to print only the specified field, where FIELD is one of 'title', 'username', 'password', 'url', or a custom field. The --totp option will parse any OTP URIs and print the code.
Automatically type out the password as if the user had typed it on the keyboard, where PROG is a dmenu-like program for selecting an entry. PROG defaults to 'dmenu'. This is useful when you want to automatically fill a selected password field in any application. name is the name of the database to type from. If not given, type from all databases. Use the --tabbed option to type out the username then password, separated by a tab. Use the --totp option to generate and type otp using 'otp' attribute. Use the --username option to show entry username in parenthesis during selection. Use the --xdotool option to use xdotool instead of the Python keyboard library. Useful for handling unicode input. Use --duration to specify the time in seconds for which a key should be pressed when typing (defaults to 0.012) and --delay to set the time between to separate key strokes. Note that this command is intended to be invoked via keyboard shortcut.
Add a new entry/group to the database, where PATH is the full path to the entry or group. Use -w, -a, or -s to generate a correct horse battery staple (http://xkcd.com/936), alphanumeric, or alphanumeric + symbolic password, respectively. LENGTH defaults to 5 words for -w and 32 characters for -a and -s unless otherwise specified. Use --append to append STR to the end of the generated password to meet specific password requirements. Use --fields to specify a comma separated list of custom fields to prompt for during entry creation.
Remove an entry/group from the database, where PATH is the full path to the entry or group.
Edit the contents of an entry or group, where PATH is the full path to the entry or group. You will be prompted to edit each field value. Use --field FIELD to edit only the specified field, where FIELD is one of title, username, password, url, or a custom field when editing entries. This option has no effect for groups. Use --set FIELD VALUE to set the value of a field, noninteractively for entries. Only name is supported for groups. Use --remove FIELD to remove an existing custom entry field. This option has no effect for groups.
Move an entry/group to another path, where SRC_PATH and DEST_PATH are the full paths to the source and destination items. Providing two entry paths or two group paths will move and rename the entry or group.
List entries/groups in the database, where PATH is an optional path to a entry or group. Use the --username option to show entry username in addition to title.
List entries with titles matching a regex pattern, where PATTERN is an XSLT style (https://www.xml.com/pub/a/2003/06/04/tr.html) regular expression. Use the --field FIELD option to search other string fields, where FIELD is one of title, username, password, url, or a custom field. Use the -i option to enable case insensitive searching.
Kill the background server.
Restart the background server.
Create a new database. You will be prompted for the database password and whether or not to use a keyfile. See --database and --keyfile to initialize in a non-default location.
Evaluate CODE as Python code. Variable kp is in scope

for accessing the database. ag is also available as shorthand for operator.attrgetter. If --json is provided, CODE will be evaluated and should be an expression which returns a JSON-serializable result. Otherwise, CODE is executed and the printing is left up to the user (the json library is in scope for serialization.)

Pretty print database XML to console. Passwords will appear in plaintext.

Print out a help message and exit. Use in conjunction with a command for command-specific help.
Enable debug messages.
Specify the path to the KeePass database when initializing, accessing or modifying the database. The config is ignored when this is given.
Specify the path to the keyfile when initializing, accessing or modifying the database. No effect if --database is not given.
Supply password directly (possibly insecure), or read it from stdin when supplied '-'
Don't prompt for a password when accessing or modifying the database. No effect if --database is not given.
Don't read from or write to cache while opening this database.
Timeout to read from or write to cache while opening this database. No effect if --no-cache=True
Specify path to config.
Print out version information.

~/.config/passhole.ini
Default location of config. Specify multiple databases here or edit database options. See the config section for supported directives.
~/.local/passhole.kdbx
Default location of KeePass database. Override with --database PATH
~/.local/passhole.key
Default location KeePass key. Override with --keyfile PATH or in config.

Located at ~/.config/passhole.ini by default. Can be overriden with the --config option. Each section in the config corresponds to a database. The supported options are:

Required. The path to the kdbx file.
Optional. Path to keyfile. If not given, assume database has no keyfile.
Optional. Assume database has no password and don't prompt for it. If not given, the password will be loaded from cache or the user prompted.
Optional. Don't read from or write to cache when opening this database.
Seconds to keep databases open in cache. Cache timeout is the same for all open databases and should be set in the first section in the config. The timeout timer resets with each passhole invocation. No effect if no-cache=True
Optional. Set this database as default. When using multiple databases, entry or group paths with no @[Name] database prefix are assumed to refer to this database.

All commands support multiple databases. Prefix entry or group paths with @[Name]/, where [Name] is the database name given in the config. A path with no prefix is assumed to be the default database.

# move an entry in the *test* database to the default database.
$ ph mv @test/foobar_group/foobar_entry root_entry
# list the test database
$ ph ls @test/
    

More databases may be added using the init command or manually specified in the config:

[test]
# Use this database as the default
# default: True
# Path to database (required)
database: /path/to/test.kdbx
# Path to keyfile.  if absent, assume no keyfile
keyfile: /path/to/test.key
# Does the database have a password?
# no-password: True
# Path to password cache.  If absent, don't cache password.
# Must be unique for each database
cache: ~/.cache/test_cache
    

The open_database function is available for use in scripts to conveniently open the default database. When all=True, it returns a list of tuples of the form ('[NAME]', [PyKeePass object]), where NAME is specified in the config.

from passhole.passhole import open_database
kp = open_database()
    

$ ph add github
Username: Evidlo
Password: 
Confirm: 
URL: github.com
    

$ ph add neopets -a
Username: Evidlo
URL: neopets.com
    

$ ph add social/
    

$ ph add social/facebook -s 32
Username: evan@evanw.org
URL: facebook.com
    

$ ph add social/twitter -w
Username: evan@evanw.org
URL: twitter.com
    

$ ph list
github
neopets
[social]
├── facebook
└── twitter
    

$ ph show social/twitter
Title: twitter
Username: Evidlo
Password: inns.ambien.travelling.throw.force
URL: twitter.com
    

$ ph show social/twitter --field password
inns.ambien.travelling.throw.force
    

Get title of all entries whose URLs start with 't'

$ ph eval -j 'map(attrgetter("title"), filter(lambda e: (e.url or "").startswith("t"), kp.entries))'
["twitter"]
    

Same example as above, but with multiline code in a Bash Heredoc

ph eval - <<EOF
titles = []
for e in kp.entries:

if (e.url or "").startswith("t"):
titles.append(e.title) print(json.dumps(titles)) EOF

Same example again, but using underlying PyKeePass API

ph eval -j 'map(ag("title"), kp.find_entries(url="^t.*", regex=True))'
    

Evan Widloski.

May 24, 2025

Search for    or go to Top of page |  Section other |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.