Package: kpcli
kpcliA simple command line tool to interact with KeePassX databases.KeePassXis a cross platform password management application.
It is available as a GUI application for MacOSX, Linux and Windows and as an Android app (KeePassDroid),
making it useful to manage passwords across multiple devices.FeaturesView details: list groups and entries, get details for a single entryAdd new entries and change passwords from the commandlineResolve conflicts: users may choose to keep their KeePassX database in a central location
such as Dropbox or other synchronisation software.  This results in "conflicting copies" being generated if
a opens and updates the database from more than one device.kpcliavoids these conflicts, and also provides
a utility to compare conflicting copies and identify where the conflicts lie.InstallationUsing pip:pip install kpcliFrom source:git clone https://github.com/rebkwok/kpcli.git
cd kpcli
poetry install  # pip install poetry first if necessaryConfigurationkpcliwill look for database configuration first in in environment variables, and
then in a config.ini file.The (encrypted) database password can be stored by settingSTORE_ENCRYPTED_PASSWORDto True in the config.ini file or
as an environment variable.kpcliwill prompt for the password once and then every 24 hours.NOTE:AT YOUR OWN RISK!KEEPASSDB_PASSWORDcan be set in plaintext in the config.ini file or as an environment variable if you really want to.
If noKEEPASSDB_PASSWORDis found,kpcliwill prompt for it.Config fileCreate a config file at $(HOME)/.kp/config.ini, with at least a default profile, and your
database location and credentials:[default]
KEEPASSDB=/Users/me/mypassworddb.kdbxIf your database uses a key file, provide that location too:[default]
KEEPASSDB=/path/to/mypassworddb.kdbx
KEYPASSDB_KEYFILE=/path/to/mykeyfile.keyMore than one profile can be set for multiple databases, and switched with the-pflag[default]
KEEPASSDB=/path/to/db.kdbx
KEYPASSDB_KEYFILE=/path/to/mykeyfile.key

[work]
KEEPASSDB=/path/to/workdb.kdbxBy default, passwords copied to the clipboard will timeout after 5 seconds. To change the
timeout, provide aKEYPASSDB_TIMEOUTconfig or environment variable.Environment VariablesIf no config.ini file exists,kpcliwill attempt to find config in the environment variablesKEEPASSDB,KEYPASSDB_KEYFILEandKEEPASSDB_PASSWORD(falling back to a prompt for the password).For more detailed usage, use--helpwith any kpcli command listed below.Usage:$kpcli[OPTIONS]COMMAND[ARGS]...Options:-p, --profile TEXT: Specify config profile to use  [default: default]--loglevel TEXT: [default: INFO]--install-completion: Install completion for the current shell.--show-completion: Show completion for the current shell, to copy it or customize the installation.--help: Show this message and exit.Commands:Group names and entry titles can be passed as partial, case-insensitive strings for matching.ls: List groups and entriesadd-group: Add a new grouprm-group: delete a groupget: Fetch details for a single entrycp: Copy entry attribute to clipboardadd: Add a new entryedit: Edit an entry's attributes (except password)change-password: Change entry passwordrm: Delete an entrycompare: Compare potentially conflicting copies of a KeePassX Database and report conflictsUsage ExamplesList groups and entries$kpclilsDatabase: /path/to/db.kdbx================================================================================Groups================================================================================RootInternetCommunications...$kpclils--groupcomm--entriesDatabase: /path/to/db.kdbx================================================================================Communications================================================================================my emailwork email...List groups in the database from the "work" profile:$kpcli--profileworklsDatabase: /path/to/workdb.kdbx================================================================================Groups================================================================================RootWork...Get an entryBy group and entry title, separated with /.  Note partial matches are allowed.If multiple matching entries are found, all will be listed.$kpcligetcomm/emailDatabase: /path/to/db.kdbx================================================================================Communications/my email================================================================================name: Communications/my emailusername: my@email.compassword: **********URL:Notes: This is my main email addressCopy an attribute (default password) from an entry to the clipboardIf multiple entries match, kpcli prompts for a selection.
Password copy times out after 5 seconds by default (change by settingKEEPASS_TIMEOUTinconfig.ini)$kpclicpcomm/emailEntry: Communications/my emailPassword copied to clipboard; timeout in 5 secondsPress any key to clear clipboard and exit:$kpclicpcomm/emailusernameEntry: Communications/my emailusername copied to clipboardCopy both username and password from an entry to the clipboardCopies first the username, waits for a keypress, then password.$kpclicpcomm/emailbothEntry: Communications/my emailUsername 'me@myemail.com' copied to clipboardPress any key to copy password: cPassword copied to clipboard; timeout in 5 secondsPress any key to clear clipboard and exit:Add an entry$kpcliaddkpcliwill prompt for required fields.Change a password$kpclichange-passwordcomm/emailkpcliwill prompt for new password.Compare conflicting databasesIn the example below,kpclifound one conflicting db to compare.The entry with title "entry1" in group "blue" is present in the conflicting db, but missing
in the main db.Entry blue/entry2 is present in the main db but missing in the conflicting db.Entry red/entry3 is present in both dbs, but has conflicting username and password values.$kpclicompareDatabase: path/to/db.kdbxDatabase password:Looking for conflicting files...================================================================================Comparison db: path/to/db_conflicting_copy.kdbx================================================================================╔════════════╤═════════════╤════════════════════╗║ Main       │ Conflicting │ Conflicting fields ║╠════════════╪═════════════╪════════════════════╣║ -          │ blue/entry1 │                    ║╟────────────┼─────────────┼────────────────────╢║ blue/entry2│ -           │                    ║╟────────────┼─────────────┼────────────────────╢║ red/entry3 │ red/entry3  │ username, password ║╚════════════╧═════════════╧════════════════════╝