Package: keepasxcli-wrapper
Keepassxc-cli WRAPPERCreate a wrapper aroundkeepassxc-cli opencommand and keep it open without need of keep the terminal open.
It allows you to access any password (or other attributes) from database interminalorscriptswithout
need of providing the password to the database again.installI strongly recommend use ofpipxto install keepassxc-cli.pipxinstallkeepasxcli-wrapperEventually you can install it by yourself in globalpipinstallkeepasxcli-wrapperor better in some virtualenv, for example like this:python-mvenv~/.keepassxcli-wrapper
.keepassxcli-wrapper/bin/pipinstallkeepasxcli-wrapperecho"alias kpowg=~/.keepassxcli-wrapper/bin/kpowg">>.bashrcecho"alias kpowr=~/.keepassxcli-wrapper/bin/kpowr">>.bashrcHow it worksWhen you ask for a password for some entry in keepassxc db and the db is not open yet, you will be prompted for
the keepassxc database password. It will start a server in a background with openedkeepassxcli opensession.
If you ask for some entry's password again, you get the password from the existing server. The connection with the server
is maintained with a file sockets. This limits usage for linux and OSX.One socket file can have only one
database.# server is not running>ps-x|grepkeepasxcli_wrapper/server.py|grep-vgrep|wc-l0# first time usage trigger prompt for database file and password>kpowrls
Opendatabase:path/to/db.kdbx
Password:
gmail
facebook# server is running now in background>ps-x|grepkeepasxcli_wrapper/server.py|grep-vgrep|wc-l1# no password is required>kpowrls
gmail
facebook
>kpowgfacebook
passwordforentryfacebookhasbeenclipped# quiting server>kpowrquit
>ps-x|grepkeepasxcli_wrapper/server.py|grep-vgrep|wc-l0# open db again>kpowrls
Opendatabase:ExamplesThere are two scripts. Both can open db.kpowg(KeePassxc Open Wrapper Get)is for accessing entry's attributes.kpowr*(KeePassxc Open Run) is for run command on originalkeepassc-cli opensession.kpowgEithercliporprinttheattributesfor the entries.clip thepasswordfor gmail in the db (gmail is the title of entry)>kpowggmail
passwordforentryfacebookhasbeenclippedclip theusernamefor gmail>kpowggmailusername
usernameforentryentry1hasbeenclipped(-s/--show)print theusername(it is printed without new line at the end)>kpowg--showgmailusername
xyz@gmail.comA partial name let you choose between all the matches.>kpowgmail[1]gmail[2]yahooe-mail

Chooseentry1-2(default1):2passwordforentryyahooemailhasbeenclippedUse(-np/--no-prompt)in script to prevent from prompt. If the db is not open it will fail, but it will not
block the rest of script.#! /bin/sh
GMAILPASSWORD="$(kpowg -np -s gmail)"(-wfp/--window-for-password)will create dialog window for password input. Use for scripts running in
background. Use in the pair with -np in case of wrong db path configuration.#! /bin/sh
GMAILPASSWORD="$(kpowg --wfp -np -s gmail)"kpowrThis just pass commands tokeepassxcli-cli.!!! WARNINGkpowr add --password-promptandkpowr edit --password-promptis not yet supported.help# show help for kpowr>kpowr--help# show help for keepassxc-cli>kpowrhelp# show help for keepassxc-cli add entry>kpowrhelpaddsome useful commands# add entry gmail-for-work with usernam work@gmail.com and autogenerated password>kpowradd-g-uwork@gmail.comgmail-for-work# change url for previous password>kpowredit--urlhttps://gmail.comgmail-for-work# move entry to Recycle Bin>kpowrrmgmail-for-workConfigurationYou are always prompt for db path. You can tellkpowrorkpowgwhere the database file exists
viaconfiguration fileorENVIRONMENT VARIABLES.Simple one database only usageInsert in .bashrcexportKEEPASSXCCLI2_NONAME_DB=/path/to/db.kdbxMultiple databasesMultiple databases require multiple entries in config file (or env).File configConfig file can be passed with(-cf/--config-file). ie:kpowg -cf path/to/mycfg.ini gmail. Also looking in
these files:~/.keepassxccli2.ini~/.config/.keepassxccli2.ini
Result is merged from all founded files, but passed file has priority in case of conflict.# default database (if you do not specify (-n/--name) in kpowg/kpowr command[noname]db=/my/persona/db.kdbx# for noname db is setup default file for socket# other custom db must contain pid_file for socket communication between kpowg/kpowr and server[work]# db is optional, but you will be prompted each timepid_file=/tmp/work_keepassxc[work2]db=/path/to/work2.kdbxpid_file=/tmp/work2_keepassxc[work3]db=/path/to/work3.kdbxpid_file=/tmp/work3_keepassxc# path to key filekey_file=/path/to/keyfile# yubikey slot[:serial]yubikey=1:7370001# for bigger databases could be default (0.3) timeout not enough to read all entries (in seconds)timeout=0.5ENVSame config can be achieved with setting ENV. In case of conflict (ENV and config is set for same name)
theENVhas priority. So you can use ENV for override config. Format isKEEPASSXCCLI2_{{NAME}}_{{ATTR}}.exportKEEPASSXCCLI2_NONAME_DB=/my/persona/db.kdbxexportKEEPASSXCCLI2_WORK_PID_FILE=/tmp/work_keepassxcexportKEEPASSXCCLI2_WORK2_DB=/path/to/work2.kdbxexportKEEPASSXCCLI2_WORK2_PID_FILE=/tmp/work2_keepassxcexportKEEPASSXCCLI2_WORK3_DB=/path/to/work3.kdbxexportKEEPASSXCCLI2_WORK3_PID_FILE=/tmp/work3_keepassxcexportKEEPASSXCCLI2_WORK3_KEY_FILE=/path/to/keyfileexportKEEPASSXCCLI2_WORK3_YUBIKEY=1:7370001exportKEEPASSXCCLI2_WORK3_TIMEOUT=0.5Example:>kpowgfacebook# open /my/persona/db.kdbx from configPassword:
passwordforfacebookhasbeenclipped

>kpowg-nwork2gmail# open /path/to/work.kdbx from configPassword:
passwordforentrygmailhasbeenclipped