keepassxc icon indicating copy to clipboard operation
keepassxc copied to clipboard

Pass command line credentials and key files to single instance

Open kareliot opened this issue 6 years ago • 8 comments

It would be very nice to have a way to automatically unlock a database after unlocking the session. Especially for cases where the setting "Close database when session is locked" is turned on.

Expected Behavior

Provide a way to open/unlock a database of an running instance of keepassxc, similar to the method used for autostart on login (which on gnome/linux would be something like:"secret-tool lookup 'keepass' 'passwords' | keepassxc --pw-stdin path/to/database.kdbx")

Current Behavior

If I try to open a database (with the above --pw-stdin command) when an instance of keepassxc is already running, I just get "Another instance of KeePassXC is already running"

Possible Solution

Provide a way of sending a password (for a closed database) to a running instance of keepassxc via the command line

Steps to Reproduce (for bugs)

  1. start keepassxc with closed database (such as you would have after automatically locking the session of the os)
  2. try to open a database from the command line with the --pw-stdin command
  3. You get a message at the terminal telling you that another instance of keepassxc is already running

Operating system: Arch Linux, Gnome

kareliot avatar Jul 03 '18 15:07 kareliot

Good idea

droidmonkey avatar Jul 03 '18 17:07 droidmonkey

Duplicate of #1405

TheZ3ro avatar Jul 03 '18 19:07 TheZ3ro

No, this is definitely not a duplicate of #1405 ! I even posted the solution from #1405 in my first comment and explicitly stated that it does not work here.

The scenario in #1405 is about starting keepassxc with the -pw-stdin argument. That works fine (as stated above). However, this issue is about passing the -pw-stdin argument to an already running instance of keepassxc so that a database can automatically be opened when a dbus event is triggered or when unlocking the session. One workaround would of course be to automatically close/kill keepassxc when locking the session and then start it again when unlocking, but this is really more of a workaround then a solution I guess.

kareliot avatar Jul 04 '18 07:07 kareliot

Sorry, missed that in the first comment :)

TheZ3ro avatar Jul 05 '18 13:07 TheZ3ro

#6143 KeePassXC-Browser 1.7.6 KeePassXC 2.6.4

  1. Please make it possible to open multiple databases from the command line and keep them open and available. I would suggest adding an additional command line option: --background or --daemon or --load.

The trick is knowing which key goes with which database that is why I suggest being able to add a database/key single command and add talk to a running process and add them in an open state.

keepassxc /path/to/database01.kdbx -k /home/jdoe/keyfile01.key --background --minimized keepassxc /path/to/database02.kdbx -k /home/jdoe/keyfile02.key --background --minimized keepassxc /path/to/database03.kdbx -k /home/jdoe/keyfile03.key --background --minimized

  1. Please make the MinimizeOnStartup an command line option, so I can script the start of the application as minimized but when the user loads the application manually it starts normally and not minimized.

I will donate an other 150 euro if the above features get implemented in the KeePassXC 2.6.5 release.

Jelle de Jong

tuxcrafter avatar Feb 18 '21 19:02 tuxcrafter

Some KDE apps have command line arguments to run in single-instance mode. For example, kate has a -u|--use switch to reuse a running instance when opening a file. The same can be added to KPXC when opening DBs from CLI. Then -u --pw-stdin would open in the running instance, using the supplied password.

But that said, if trying to open a 2nd instance just gives an error, then an extra switch isn't useful. It should just be the default behavior instead of the error.

michaelk83 avatar Apr 17 '21 17:04 michaelk83

What if keepassxc itself would send dbus messages a.la. https://github.com/keepassxreboot/keepassxc/wiki/Using-DBus-with-KeePassXC to unlock the database in the running instance? It doesn't sound complicated, but then I don't know a thing about the code base :-)

(Btw, the dbus examples in the linked wiki page leak the password in process listings. Eek!)

bjornfor avatar Nov 17 '22 18:11 bjornfor

Dbus only exists on linux.

droidmonkey avatar Nov 17 '22 21:11 droidmonkey