Man, talk about post titles that either pique interest or turn people off VERY quickly, lol.
TL;DR: Using fzf, you can get your passwords out of your Keepass database from the commandline easily with this script. See the animated GIF below if you’re not sure how this would be useful.
I have long been a fan of Keepass, KeepassX, and KeepassXC – all part of the informal “Keepass Family”. These programs have always been a good way to have a free – or very low cost – synchronized cross-platform password manager that’s entirely in your control.
Each version has its pluses and minuses, though I’ve settled with KeepassXC.
KeePassXC is a free and open-source password manager. It started as a community fork of KeePassX. It is built using Qt5 libraries, making it a multi-platform application which can be run on Linux, Windows, and macOS. KeePassXC uses the KeePass 2.x password database format as the native format.https://en.wikipedia.org/wiki/KeePassXC
But I’ve been living in the terminal more, and so I wanted something that I could quickly pull up in a tmux window or somesuch. While there is a command-line interface for KeepassXC, with all the features, it is a bit cumbersome for “show me the password for this entry”.
While there are some helper scripts out there, they’re in python or other languages, sometimes unmaintained, and hugely complicated for my use case. So I made kpf.sh .
It will help you choose the database file (using fd – fdfind on Debian) presuming it’s got a kbdx extension) and enter the password for the file. (Or if you want to be insecure, you can also set them as environment variables:
export KPPW="Your KeepassxC password"
Then you can use fzf to select the appropriate key (and see a preview to the side). Upon selecting a key, the password is copied to the PRIMARY clipboard (thanks to xsel) and the username and TOTP entry (if any) are displayed on the terminal.
As written, it obviously requires fzf, and keepassxc-cli, xsel and fd (or fdfind). If you’d rather use find, you’re welcome to edit the script; I dashed this together for my own use (and you probably should install fd anyway, it’s pretty awesome). On Debian (bullseye, at least), you can get those prerequisites with a simple:
sudo apt install fd-find fzf keepassxc xsel
And you can find the script in my “multiple scripts” repository, or just pull the script itself from https://github.com/uriel1998/multiple_scripts/blob/master/kpf.sh