Menu

keepass2 2.47+dfsg-2 (Debian Linux): auto-type does not work

2024-05-07
2024-07-03
  • Frank B. Brokken

    Hi all,

    Using Debian Linux's trixie distribution, I upgraded 'keepass' to 'keepass2' yesterday.
    Since the upgrade Auto-Typing doesn't work anymore.

    Reading through the user info I noticed that keepass2 requires the xdotool. I already had installed xdotool,
    and when I'm opening an rxvt terminal window named 'rxvt' and run the command

    xdotool search --name rxvt
    

    I receive:
    16777227
    and then, when issuing the commands
    xdotool type --window 16777227 ls
    xdotool key --window 16777227 Return
    the 'rxvt' window neatly executes its 'ls' command. So xdotool apparently works.

    In the usage info I also read that the --auto-type (two initial dashes, or is it -auto-type, single initial dash?) should be provided when starting xkeepass2.
    I did both:
    /usr/bin/keepass2 --auto-type ~/etc/keepass.kdbx
    and
    /usr/bin/keepass2 -auto-type ~/etc/keepass.kdbx
    but in both cases nothing happened, i.e., keepass2 didn't start and didn't issue an error or other message.

    'keepass2' does show an (already existing) entry in its keepass.kbdx file:

    Title   User Name   Password    URL     Notes
    rxvt    crypt -x    ******              hdu
    

    and when I enter in the 'rxvt' window:
    crypt -c hdu
    then highlighting the rxvt line in the list of keepassx.kbdx entries, followed by ctrl-C, the correct password,
    using the mouse's middle kkey, is nicely inserted in the rxvt window.

    In rxvt's Auto-Type tab 'Enable auto-type for this entry' is active, as is the Override default sequence:
    {USERNAME}{ENTER}{DELAY 1500}{PASSWORD}{ENTER}

    Either using the 'default keystroke sequence of the entry' (as used with keepass) or explicitly inserting the
    abovementioned overridden default sequence and activating its 'Use custom keystroke sequence' makes no
    difference: neither specification results in inserting the sequence into the 'rxvt' window.

    I tried to use the insertion command used in keypass (ctrl M), as well as the
    command ctrl-alt-a, but no sequence is auto-typed into the 'rxvt' window.

    I think I'm stuck, and don't grasp what it is I should do to make keepassx2 perform auto-typing like keepass did.

    Maybe somebody can tell me what I should do to make it work again?

     
  • Dominik Reichl

    Dominik Reichl - 2024-05-07

    You need to create a system-wide hot key, as described in the section 'Global Auto-Type' here:
    https://keepass.info/help/v2/setup.html#mono

    Best regards,
    Dominik

     
  • Frank B. Brokken

    Thank you for your reply. However, I read that page yesterday too, and that's where I found --auto-type being mentioned (which, when specified, doesn't start keepass2...) Unfortunately the help info only describes menu mouse clicks, which is nice for a window manager (WM) offering a graphical user interface, but doesn't explain how to define a Global Auto-Type if there is no graphical user interface (like the 'afterstep' WM I'm using). But the examples suggest that the command to issue is 'mono /path/to/keepass2 --auto-type'. When I try that I get the message
    'Cannot open assembly '/usr/bin/keepass2': File does not contain a valid CIL image.'
    and nothing else happens. And just for the record: this is when using the mono-complete package.
    Mono's installed when installing keepass2, so I guess that's the one that's needed. In any case, the one I'm using is version 6.8.... which should be recent enough, right?
    The page also specifies that the xdotool must be at least version 2.20...., In my case it's 3.20..., so that should also be no problem.
    Maybe there's a simple solution to the problem, but so far I didn't find it, unfortunately. Maybe there's another approach I can follow?

     
  • Paul

    Paul - 2024-05-07

    You are correct, the AT command is added manually.
    Are you sure you added the entire path for the KeePass executable?
    Something like: mono /usr/bin/keepass2/keepass.exe --auto-type

    mono complete is only required for plug-ins to compile.

    cheers, Paul

     
  • Frank B. Brokken

    Hi Paul,
    Thx for your posting. And NO no keepass.exe as Linux doesn't use the .exe extension. In Debian Linux's trixie distribution the keepass program is available from the keepass2 package, installing /usr/bin/keepass2. There is no /usr/bin/keepass2 directory:
    $ ls /usr/bin/keepass*
    shows:
    /usr/bin/keepass2
    and just to be sure I reissued
    mono /usr/bin/keepass2 --auto-type
    resulting in
    Cannot open assembly '/usr/bin/keepass2': File does not contain a valid CIL image.
    end ending 'mono'
    Puzzling....

     
  • Paul

    Paul - 2024-05-08

    KeePass.exe is used, it's "mono" that is the executable.

    I don't have Debian to test, but you should find a file with keepass in the name, around 3MB in size. Do you have such?

    cheers, Paul

     
  • Frank B. Brokken

    Wow, Paul!

    That at least clarified something (although it doesn't properly work (yet)). It turns out that keepass2 is a script doing
    exec /usr/bin/cli /usr/lib/keepass2/KeePass.exe "$@"
    so, yes, the executable, even on Linux systems, is named ...exe.

    OK, now that that's clarified, here's what I did next:
    mono /usr/lib/keepass2/KeePass.exe ~/etc/keepass.kdbx --auto-type
    but that doesn't start KeePass.exe (i.e. it immediately stops, without an error message)
    Next I issued
    mono /usr/lib/keepass2/KeePass.exe ~/etc/keepass.kdbx
    So, w/o --auto-type: that started KeePass.exe, but no auto-type occurs when I issue ctrl-alt-a in the rxvt window.
    I also tried to merely start KeePass.exe specifying --auto-type:
    mono /usr/lib/keepass2/KeePass.exe --auto-type
    but this command, like the previous one where --auto-type was specified, didn't start KeePass.exe

    So thanks for your helpful posting. Now the question that remains is how to activate auto-typing, right?

     
  • Paul

    Paul - 2024-05-09

    First you need to run KeePass and unlock your database. Now lock the database. This leaves KeePass running with the database location in memory.
    Open a browser window and get up a login prompt.

    To make KeePass Auto-Type you need to call it thus: mono /usr/bin/cli /usr/lib/keepass2/KeePass.exe --auto-type
    KeePass should pop up and request your master key, then it will search for a match in the database.

    If you list the global shortcuts that are already created you should see one for Ctrl Alt A with a command like the one above.

    cheers, Paul

     
  • Frank B. Brokken

    Hi Paul,
    First of all: I really value the support you're offering. With a bit of luck I'll get Keepass.exe working.

    The confusing part --at least for me-- is that the previous keepass version ran flawlessly while somehow keepass2 doesn't properly seem to auto-type (yet)....

    The advice to run KeePass and unlock the data base, then lock it etc. is a new one, but OK: I did that: KeePass.exe runs, and I locked the database via the File->Lock Workspace menu entry. It clears the keepass database showing window. But what you mean by 'Open a browser window and get up a login prompt.' is confusing. In order to write this posting I already opened my browser and it already requested the browser's database password, and it won't do that again. But locking and unlocking works fine.
    Other than that, when issuing
    mono /usr/bin/cli /usr/lib/keepass2/KeePass.exe --auto-type
    I get a comparable reply as I mentioned in one of my earlier postings:
    Cannot open assembly '/usr/bin/cli': File does not contain a valid CIL image.
    and (just to be sure): mono is /usr/bin/mono, which is a soft-link to /usr/bin/mono-sgen, which is installed by the mono-runtime-sgen package which is package automatically installed when installing the mono-runtime package, which offers /usr/bin/mono.
    Wrt listing global shortcuts: how do I do that? I don't see a 'list global shortcuts' or comparable entry in the menu entries, but the edit window of my 'rxvt' database entry specifies 'Enable auto-type'.
    It's likely that the solution to my problem, in the end, turns out to be a simple one, resulting from something that was overlooked. But so far that solution hasn't emerged, right?

     
  • Paul

    Paul - 2024-05-09

    Sorry I missed part of your post that indicated the correct KeePass path.
    The command to try for Auto-Type is: mono /usr/lib/keepass2/KeePass.exe --auto-type

    Locking KeePass will force the Auto-Type command line option to fire up KeePass and prompt for the master key. This shows the command is working even if no AT match is found.

    Bring up a browser window with a login prompt. Use this URL as the test: https://keepass.info/help/kb/testform.html

    To find the global shortcuts go to (I think this is right) Settings > Keyboard, shortcut keys.

    cheers, Paul

     
  • Frank B. Brokken

    Hi Paul,
    Fast! :-)

    However, I did try
    mono /usr/lib/keepass2/KeePass.exe --auto-type
    before but (see my earlier postings) when starting mono with the keepass argument and --ato-type option I always receive a reply like
    Cannot open assembly '<1st argument passed to mono>': File does not contain a valid CIL image.

    Mono's man-page does state that its file argument typically has a .exe extension, so wrt that we're fine, but the error message itself doesn't really help me. In any case the command doesn't do anything except for immediately ending 'mono'

    So far the only way to start KeePass.exe is to call it (passing it the keepass.kdbx file), without the --auto-type option, either or not via mono (mono /usr/lib/...). Once --auto-type is specified things break.

    Puzzling....

     
  • Paul

    Paul - 2024-05-09

    Call KeePass without specifying the database. This should just open KeePass / bring up a minimized KeePass.
    Leave KeePass up or minimize, but do not close it.

    Now try with --auto-type.

    cheers, Paul

     
  • Frank B. Brokken

    Interesting, and thanks again for your continuing support.

    Here's what I did:
    /usr/lib/keepass2/KeePass.exe
    this starts KeePass.exe, showing its login window.
    Leaving that window as-is I executed
    /usr/lib/keepass2/KeePass.exe --auto-type
    that command showed no output and does not result in a 2nd keepass process. Then,
    logging in at the keepass login window opens keepass.kdbx, but no auto type results when typing ctrl-alt-a.
    In case you mean by 'try with ...' to merely start keepass2 using
    /usr/lib/keepass2/KeePass.exe --auto-type
    I did that too, but then again there's no output, and there's no keepass process running. Also when using the /usr/bin/keepass2 command, which executes cli, with KeePass.exe as its argument: this doesn't start a keepass process when specifying the --auto-type argument. I get the impression that --auto-type is maybe not supported: whenever it's specified keepass doesn't start....

     
  • Paul

    Paul - 2024-05-09

    "--auto-type" tells the existing KeePass instance to perform Auto-Type.
    If there is no KeePass running, nothing happens.
    If there is no match, nothing happens.
    If KeePass is locked, it pops up the master key dialog. This then allows KeePass to search for a match.

    Open KeePass, then lock it and do NOT close it.
    Run the "--auto-type" command to make KeePass pop up the master key dialog.

    cheers, Paul

     
  • Frank B. Brokken

    Correct me if I'm doing something not right, but here's what I did:
    First, I started keepass2, which executes KeePass:
    exec /usr/bin/cli /usr/lib/keepass2/KeePass.exe "$@"
    I logged in, opened keepass's File menu, selected 'File -> Lock Workspace'. So far, so good.
    Then I executed keepass2 --auto-type.
    The KeePass master key dialog popped up, I provided the required password, and the keepass.dbx - KeePass screen showed its entries again.
    Then I opened the browser to post this message. The browser requested the password allowing it to access its own passwords so I can login at sourceforge.net. I typed ctrl-alt-a, but nothing happened, and I had to enter the password manually.
    Just to be sure I also tried to make kepass auto-type in my 'rxvt' window, but there too nothing happened. Apparently there's no auto-typing happening, although, AFAICS I followed your advice. Weird, isn't it?

     
  • Paul

    Paul - 2024-05-10

    You have confirmed that the commands work. This is a good start.
    When you ran "keepass2 --auto-type", exactly what command did you run? Your description suggests the auto-type argument was not passed because KeePass stayed up - it should never show anything except the master key prompt.

    I don't get this bit?

    The browser requested the password allowing it to access its own passwords

    Are you using the browser to store passwords? If so, why, you have a password manager?

    cheers, Paul

     
  • Frank B. Brokken

    Hi Paul,
    Thanks again for your support!
    keepass2 --auto-type
    executes
    /usr/bin/keepass2 --auto-type
    which in turn executes
    exec /usr/bin/cli /usr/lib/keepass2/KeePass.exe --auto-type

    And yes, I'm also using the browser to store passwords, but those are the ones used when browsing, and after entering the browser's password UN/PWs required for websites are automatically entered. But I also use command/password specifications in several other windows (comparable to the 'rxvt' example that I used in previous postings). So for all those situations I could perfectly use the auto-type facility offered by the former keepass version, which I did for maybe more than 10 years....

    It's unfortunate that, apparently, keepass2's implementation has thoroughly been altered, resulting in a long fight to get its auto-type facility working like before.

    Frankly, I get the impression that, with all due respect for your continuing help, we're flogging a dead horse, and considering that (see my initial posting, three days ago) it's not hard to write a program that enters a command in a specific window by simply using xdotool, accessing the required commands for specific windows from its own database I'm probably gonna take that route. Not as nice as the former facility offered by keepass, but at least it'll work.

    So thanks again for all your support, but for now I realize that I've lost the battle with keepass2. Hopefully/maybe there will once be a keepass3 that can be used again like the previous keepass version.

    Cheers,
    Frank.

     
  • Paul

    Paul - 2024-05-11

    KeePass 2 Auto-Type works the same as KeePass 1.
    Making it work under Linux requires a little more effort.

    cheers, Paul

     
  • Frank B. Brokken

    Hi all,
    The other day a friend of mine pointed me to keepassxc. I installed it and it immediately worked like a charm. It's very well documented, and also available on Windows and MacOS (cf. https://tracker.debian.org/pkg/keepassxc). One small configuration advice: in Settings -> Auto-Type the option 'Always ask before performing Auto-Type' is active by default. Deactivate it to allow keepassxc to directly perform auto-typing in configured windows. Anotther related advantage of dropping keepassx is that some 20+ (lib)mono-related packages became superfluous and could also be removed.

     

Log in to post a comment.