kdbx-cli is an interactive command-line interface for the KeePass password database (.kdbx).
- Thin wrapper over the pykeepass library as the only dependency except the standard Python modules and pyotp for one-time passwords
- Runs as a single process to avoid the complexity of securing inter-process communication (unlike passhole which keeps a background process)
- Interoperable with KDBX 4.0, KeePassXC and Keepass2Android Offline
- Clipboard integration (using
xsel
by default) - Auto-erase clipboard (after
10
seconds by default) - Auto-completion using the
tab
key - No destructive operations
- Every change is saved to entry history
- Deleted entries are moved to
Recycle Bin
- Prevent overwriting the database file when its modified time changes (not atomic)
- For file synchronization use e.g. Syncthing with Staggered File Versioning
- Copying entries to another database file
- Print QR codes (using the pipe commands; run e.g. with
--pipe "qrencode -t utf8"
) - SSH integration (using the included scripts sshgen, sshknown)
- Custom Attributes
- Notes are line-separated and prepended with a label
- Database files can be protected only by a password
- New entries can be created only in the root group
- Entry titles with spaces are not supported in commands with multiple parameters (but can be changed using
rename
) - No GPG integration (e.g. by forwarding gpg-agent)
- Not published to PyPI yet
Copy/clone the kdbx-cli
script and make it executable.
Install pykeepass:
pip3 install -r requirements.txt
MacOS requires additional configuration for GNU readline interface to make tab-completion work:
tee ~/.editrc << EOM
python:bind ^I rl_complete
EOM
brew reinstall readline
MacOS uses pbcopy
instead of xsel
:
alias kp='kdbx_cli.py --clip "pbcopy" --paste "pbpaste"'
On Windows or WSL, win32yank
can be used (e.g. installed with neovim by default):
alias kp='kdbx_cli.py --clip "win32yank.exe -i --crlf" --paste "win32yank.exe -o --lf"'
Start the interactive CLI with:
kp FILENAME
Use the tab
key for auto-completion.
General
help
list all commandsq
quit- press
Ctrl
+D
to quit andCtrl
+C
to interrupt ls
list entrieslt
list entries by modified timefind STRING
find entriesdig STRING
find entries in recycle bins [TITLE]
select entry by titleadd TITLE
new entry with titlerename TITLE
change titlerm ENTRY...
move entries to recycle binrestore ENTRY...
restore entries from recycle bincp FILE ENTRY...
copy entries to db filemv FILE ENTRY...
copy entries to db file, then move to recycle bindedup
number duplicate titlespasswd
change db passwordc
clear clipboard
Read Entry
dump
display fieldshistory
display changesh [TIME]
select history itemp
clip passwordpd
display passwordpc
pipe passwordps
partially display passwordpv
verify passwordu
clip usernameud
display usernameuc
pipe usernamel
clip location (URL)ld
display location (URL)lc
pipe location (URL)n LABEL
clip note by labelnd LABEL
display note by labelnc LABEL
pipe note by labelndump
display notesa LABEL
clip attribute by labelad LABEL
display attribute by labelac LABEL
pipe attribute by labelas LABEL
partially display attribute by labelssh [TIME]
ssh-add private key (from password)sshknown
add to known_hosts (from URL)otp
clip TOTPotpd
display TOTPotpuri
display OTP uri
Modify Entry
pput
change passwordppaste
paste new passworduput
change usernameupaste
paste new usernamelput
change location (URL)lpaste
paste new locationnput LABEL
change note by labelnpaste LABEL
paste new note with labelnrm LABEL
remove note by labelaput LABEL
change attribute by labelapaste LABEL
paste new attribute by labelarm LABEL
remove attribute by labelotpput
change TOTP secretotppaste
paste new TOTP secret
Generate Entry Passwords
agen LABEL SIZE
generate new printable attributeagena LABEL SIZE
generate new alphanumeric attributeagend LABEL SIZE
generate new digit attributeagenc LABEL SIZE
generate new crockford attributepgen SIZE
generate new printable passwordpgena SIZE
generate new alphanumeric passwordpgend SIZE
generate new digit passwordpgenc SIZE
generate new crockford passwordsshgen
generate ssh keys