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

Basic CLI #207

Closed
wants to merge 4 commits into from
Closed

Basic CLI #207

wants to merge 4 commits into from

Conversation

KeyWeeUsr
Copy link
Contributor

@KeyWeeUsr KeyWeeUsr commented Oct 12, 2020

Issue #205 made me thinking about the current usage and basically we have the API/backend ready, but there's an opportunity to take with missing frontend. For that we can use argparse and create a basic set of commands for managing kdbx from CLI. This will bring wider audience to the library especially if we'd create a PPA for Debian-based distros and provide a binary for Windows + MacOS.

It's not meant as a full standalone KeePass client as with other GUIs (although if we find a client to auto-type, it might work that way too), but as a quick tool for various bulk automation or for migration between password managers without knowing Python itself (e.g. just use bash).

Example:

$ pykeepass -p password -f ~/Desktop/mydatabase.kdbx tree
[Root]
|-- [foobar_group]
|   |-- [subgroup/name]
|   |   |-- subentry
|   |   |-- subentry2
|   |   `-- foobar_entry
|   |
|   |-- group_entry
|   `-- foobar_entry
|
|-- [foobar_group2]
|-- [Работа]
|   `-- Тест
|
|-- root_entry
`-- test/name

Closes #205, at least I think it'd be sufficient based on this comment.

@Evidlo
Copy link
Member

Evidlo commented Oct 15, 2020

So we talked about this a bit in the Matrix room. I think this makes more sense for it to live in its own package/repo.

Also I mentioned the existence of passhole. Some commands don't explicitly support non-interactive mode, but you can easily get that by piping text.

(on master branch)

entry=test_entry
username=user
url=http://example.com
password=hello

ph add ${entry} << EOF
${username}
${password}
${password}
${url}
EOF

# alternatively

ph add ${entry} <<- EOF
	${username}
	${password}
	${password}
	${url}
EOF

@Evidlo
Copy link
Member

Evidlo commented Jan 4, 2021

Another alternative for scripting

filename=test4.kdbx
password=password
keyfile=test4.key

entry_title=test
entry_user=user
entry_pass=pass

python - << EOF
# see pykeepass_cache to avoid decrypting database for each python invocation
from pykeepass import PyKeePass
kp = PyKeePass("${filename}", "${password}", "${keyfile}")
print(kp.entries)
EOF

Thanks for the work on this nonetheless.

@Evidlo Evidlo closed this Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unescaped slashes for entry names/paths
2 participants