Skip to main content

kpsh

kpsh, or KeePass Shell, is a password manager and an interactive shell for working directly with KeePass password database files.

Features

  • create, open, lock and unlock databases
  • add, edit and delete database entries
  • list contents of database
  • show contents of database entries and filter them by fields
  • autotype usernames and passwords or any sequences of entry fields (by xdotool on X11 and ydotool on Wayland)
  • access all commands non-interactively via -c switch or by piping commands directly to kpsh
  • tab-completion in interactive mode
  • daemon mode: open and unlock your database once and then quickly access its contents from kpsh-client.
  • several built-in ways to obtain a password, which can be passed by argument, typed directly to kpsh or through pinentry program program or fetched from a provided command output
  • ships with highly customizable kpsh-menu script which performs any kpsh command on entries selected by dmenu/rofi/fzf (e.g. autotype passwords selected in dmenu/rofi)

Online Documentation

https://pages.goral.net.pl/keepass-shell

Usage examples

Typical session:

$ kpsh passwords.kdbx

passwords.kdbx> ls
Password: ********
personal/bank
personal/login
personal/website
work/login

passwords.kdbx> show work/login
path: work/login
username: John Doe
password: jsdf7y8h8349yhj3h42
notes[1]: this is my work password
notes[2]: it's the best

Get a password from gpg-encrypted file (trailing newline, which isn't a part of password is trimmed):

$ gpg --encrypt -o masterpass.gpg -r mymail@example.com
<type type type>
^D
$ kpsh passwords.kdbx --password-command "gpg --decrypt masterpass.gpg | tr -d '\n'"

... or from a keyring:

$ secret-tool store --label='keepass' database passwords.kdbx
$ kpsh passwords.kdbx --password-command "secret-tool lookup database passwords.kdbx"

Autotype a user/password sequence:

$ kpsh passwords.kdbx --password-command "secret-tool lookup database passwords.kdbx"
                      -c autotype entry1

... or just a password, but a little faster:

$ kpsh passwords.kdbx --password-command "secret-tool lookup database passwords.kdbx"
                      -c "autotype -s {PASSWORD} -D 12 entry1"

Run as daemon (-d):

$ kpsh passwords.kdbx -d --password-command "secret-tool lookup database passwords.kdbx" &
$ kpsh-client ls
entry1
entry2
$ kpsh-client autotype entry1

Use pinentry to get a password to unlock database:

$ kpsh passwords.kdbx --pinentry /usr/bin/pinentry

Installation

Use pipx:

$ pipx install kpsh

Or directly pip:

$ pip install --user kpsh

Install fetched git repository (for example to test yet unreleased code):

$ cd keepass-shell
$ rm -rf dist
$ pipx install poetry>=1.2.0a
$ poetry build
$ pipx install dist/kpsh-*.whl

Test kpsh without installation (e.g. for development purposes)

One time setup:

$ pipx install poetry>=1.2.0a
$ poetry lock
$ poetry install

The last command installs kpsh in editable mode, meaning that it will automatically reflect changes in source code. You can safely use it to change kpsh to your liking.

Once kpsh is installed in poetry-managed virtualenv, you can run it like this:

$ poetry run kpsh

Release files for kpsh 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kpsh 2.2.0
File Size Uploaded
kpsh-2.2.0.tar.gz 62.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kpsh 2.2.0
File Interpreter ABI Platform
kpsh-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 108.1 kB

Release files / kpsh-2.2.0.tar.gz

Download URL kpsh-2.2.0.tar.gz
Size 62.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b1b78e0284f42934394647b42b45a413883d8c65bc3d5cbf53b896f5874c8792
BLAKE2b-256 checksum
How to use checksums
9447708621ffb1fb92bddacb2ebd2798b6401e3cc73126e9b799c4ce26e4d4d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.7 Linux/6.5.0-5-amd64

Release files / kpsh-2.2.0-py3-none-any.whl

Download URL kpsh-2.2.0-py3-none-any.whl
Size 45.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e32b3959df425753a30266aaa901cc8965af84135eee98e0f2d8bb86cef36bfa
BLAKE2b-256 checksum
How to use checksums
6c9516e9b6a0507a8c2c760494d86b3472e7ede5ac163c4fc156694282c7c320
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.7 Linux/6.5.0-5-amd64

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3

2 release files

0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page