My password is stored in a file and I need to automate the unlocking of the KeepassXC DB using CLI interface with a simple command on Windows (PowerShell preferably).
Get-Content -Encoding UTF8 L:\k.txt | .\keepassxc-cli.exe open --key-file '.\temp.keyx' '.\temp.kdbx'
But I keep getting the following error saying incorrect password:
Error while reading the database: Invalid credentials were provided, please try again.
If this reoccurs, then your database file may be corrupt. (HMAC mismatch)
Now, If I just run Get-Content command and copy the output as following:
Get-Content -Encoding UTF8 L:\k.txt | Set-Clipboard
and paste in the KeepassXC GUI, it works (DB get unlocked, meaning the password is correct, and the database file is not corrupted), but if I paste it in the password prompt in the CLI it doesn't work, and I get the above error message.
Why so? Is this a bug in the CLI, or am I doing something wrong?