Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Browser Integration to connect keepassxc-cli to gui #5069

Open
bendem opened this issue Jul 14, 2020 · 7 comments
Open

Using Browser Integration to connect keepassxc-cli to gui #5069

bendem opened this issue Jul 14, 2020 · 7 comments

Comments

@bendem
Copy link

bendem commented Jul 14, 2020

Summary

When using the cli, instead of specifying a path and entering your password every single time you interact with a database, connect to the running keepassxc using the browser integration.

Examples

keepassxc-cli show --from-open-databases -a Password 'Production/devops/gitea-production'

# we use ansible-vault to store secrets, passwords are in keepass
ansible-vault show --vault-id gitea-production@kpxc-prod-client some/file.vault
ansible-playbook -l prod \
  --vault-id gitea-production@kpxc-prod-client \
  --vault-id postgres-production@kpxc-prod-client \
  playbooks/gitea/setup.yml
#!/bin/bash

set -euo pipefail
set -x

readonly KP_CLI=${KP_CLI:-"$USERPROFILE/scoop/apps/keepassxc/current/keepassxc-cli.exe"}
readonly KP_ROOT=${KP_ROOT:-'Production/devops/gitea-production'}

"$KP_CLI" show --from-open-databases -a Password "$KP_DATABASE" "$KP_ROOT/$2"

Context

We use ansible and ansible-vaults to encrypt secrets, to unlock those secrets we have a script we give to ansible that fetches passwords from the keepass database. Since the cli touches the database file directly, we have to unlock the database every single time.

I saw the open feature, but this is unusable for vaults since the script is run once per password and even if it worked, it would still require the user to enter their password at least once per run.

Bonus

If all commands support the new option, the complexity of having to maintain a REPL can be entirely removed from the code.

@bendem
Copy link
Author

bendem commented Jul 14, 2020

This is kind of related to #4513 which I didn't find at first, but I feel more strongly about the solution required. Browser integration is already there, it works, I don't see any reason why the cli couldn't be yet another client of it.

As for the key, it can be stored in linux with libsecret, mac's keychain and windows probably has a thing similar. It will actually be more secure than browser's storage where it's just a file or a db in plaintext in the user's profile directory.

@droidmonkey
Copy link
Member

droidmonkey commented Jul 14, 2020

Good idea. We could have a keepassxc-cli connect command. You can enter the secret key on the cmd line, at prompting, or force a new connection.

@Frederick888
Copy link

Shameless advertisement: https://github.com/Frederick888/git-credential-keepassxc#scripting

@droidmonkey
Copy link
Member

Yes!

@bendem
Copy link
Author

bendem commented Jul 15, 2020

Shameless advertisement: https://github.com/Frederick888/git-credential-keepassxc#scripting

I wish, but that doesn't work on windows:

bendem> git-credential-keepassxc.exe configure
Jul 15 13:57:36.999 ERRO Le fichier spécifié est introuvable. (os error 2), Caused by: N/A, Message: Le fichier spécifié est introuvable. (os error 2)
[98.99 ms]

@Frederick888
Copy link

@bendem

  1. I don't speak French(?)
  2. -vv to enable verbose logs
  3. Even better, do a debug build and then -vvv
  4. You should file an issue in my repo instead

@nodiscc
Copy link

nodiscc commented Jan 28, 2024

I am after basically the same thing,e.g. keepassxc-cli show --use-proxy --show-protected -a Password /path/to/my/database.kdbx 'my-ansible-vault-password'

I posted a duplicate issue by mistake in #10238, but it also includes a workaround using https://github.com/hargoniX/keepassxc-proxy-client

The browser integration mechanism seems to be a good fit, as it provides fine-grained access to different databases/entries.

As for the key, it can be stored in linux with libsecret, mac's keychain and windows probably has a thing similar.

My workaround stores the native messaging key in plain text on disk, but +1 👍 to this idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants