Skip to main content

A simple command line tool to interact with KeePassX databases

Project description

kpcli

A simple command line tool to interact with KeePassX databases.

KeePassX is 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.

Features

  • View details: list groups and entries, get details for a single entry
  • Add new entries and change passwords from the commandline
  • Resolve 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. kpcli avoids these conflicts, and also provides a utility to compare conflicting copies and identify where the conflicts lie.

Installation

Using pip:

pip install kpcli

From source:

git clone https://github.com/rebkwok/kpcli.git
cd kpcli
poetry install

Configuration

kpcli will look for database configuration first in a config.ini file, and if one is not found, in environment variables.

NOTE: AT YOUR OWN RISK! KEEPASSDB_PASSWORD can be set in the config.ini file or as an environment variable if you really want to. Not advised unless you implement some method of encrypting and retrieving it before passing to kpcli. If no KEEPASSDB_PASSWORD is found, kpcli will prompt for it.

Config file

Create 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.kdbx

If your database uses a key file, provide that location too:

[default]
KEEPASSDB=/path/to/mypassworddb.kdbx
KEYPASSDB_KEYFILE=/path/to/mykeyfile.key

More than one profile can be set for multiple databases, and switched with the -p flag

[default]
KEEPASSDB=/path/to/db.kdbx
KEYPASSDB_KEYFILE=/path/to/mykeyfile.key

[work]
KEEPASSDB=/path/to/workdb.kdbx

Environment Variables

If no config.ini file exists, kpcli will attempt to find config in the environment variables KEEPASSDB, KEYPASSDB_KEYFILE and KEEPASSDB_PASSWORD (falling back to a prompt for the password).

Usage Examples

List groups and entries

$kpcli ls

Database: /path/to/db.kdbx
================================================================================
Groups
================================================================================
Root
Internet
Communications
...

$kpcli ls --group comm --entries
Database: /path/to/db.kdbx
================================================================================
Communications
================================================================================
my email
work email
...

List groups in the database from the "work" profile:

$kpcli --profile work ls
Database: /path/to/workdb.kdbx
================================================================================
Groups
================================================================================
Root
Work
...

Get an entry
By group and entry title, separated with /. Note partial matches are allowed.
If multiple matching entries are found, all will be listed.

$kpcli get comm/email
Database: /path/to/db.kdbx
================================================================================
Communications/my email
================================================================================
name: Communications/my email
username: my@email.com
password: **********
URL:
Notes: This is my main email address

Copy an attribute (default password) from an entry to the clipboard
If multiple entries match, kpcli prompts for a selection.

$kpcli cp comm/email
Entry: Communications/my email
password copied to clipboard

$kpcli cp comm/email username
Entry: Communications/my email
username copied to clipboard

Add an entry

$kpcli add

kpcli will prompt for required fields.

Change a password

$kpcli change-password comm/email

kpcli will prompt for new password.

For more detailed usage, use --help with 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:

  • ls: List groups and entries
  • get: Fetch details for a single entry
  • cp: Copy entry attribute to clipboard
  • add: Add a new entry
  • change-password: Change entry password
  • compare: Compare potentially conflicting copies of a KeePassX Database and report conflicts

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kpcli-0.1.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

kpcli-0.1.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file kpcli-0.1.0.tar.gz.

File metadata

  • Download URL: kpcli-0.1.0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.3 Darwin/19.6.0

File hashes

Hashes for kpcli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 abe526b6ae93e5b80186ec6d65f5bd250be73ba776028eded41408631d1ea606
MD5 035967958f12d552c09b8514b5eeaf06
BLAKE2b-256 862105f4e977bc1e37e277c4f79f3917e485014ff83e7fbb2dc7589d13650867

See more details on using hashes here.

File details

Details for the file kpcli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kpcli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.3 Darwin/19.6.0

File hashes

Hashes for kpcli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b87ed51669dcd0d1edeeaa02566cfae140f6e1deafbbbf507caefca1980a6ca
MD5 c39133f767fccaa8b1f9f93ec1378cfd
BLAKE2b-256 72f1c89f8af205188bbaa9fe9a4765fb599e7b7917cdc54a8b97020155a1f4ab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page