KeePassXC/cli

From Gentoo Wiki
Jump to:navigation Jump to:search

keepassxc-cli is a command line interface for the KeePassXC password manager.

Configuration

Files

  • ~/Passwords.kdbx - Local (default) database name.
  • ~/keepass.keyx - (optional) key file for unlocking the database.

Usage

Important
For secure database setup use the KeePassXC GUI.

keepassxc-cli provides the ability to query and modify the entries of a KeePass database, directly from the command line. This document shows a simple set of commands. Presented example commands cover most common use cases needed to create new db, add entries, list and remove entries from a example database.

Specific database entries need to be set using the KeePassXC GUI. Generating of (OTP) one-time passwords works.

Tip
Use the KeePassXC GUI to add a Base32 secret to the database entry.

db-create

Create a password database named Passwords.kdbx, the KeePassXC default database name, ask to set a database password:

user $keepassxc-cli db-create -p Passwords.kdbx

db-info

Show technical information about the created database ~/Passwords.kdbx:

user $keepassxc-cli db-info Passwords.kdbx

2 database entries are empty using shown syntax.

  • Name:
  • Description:

Find and use additional keepassxc-cli commands to setup both (optional) entries.

open

Open passwords database, authenticate to the database, show ready prompt:

user $keepassxc-cli open Passwords.kdbx

Use the quit command to exit.

Passwords.kdbx>exit

add

Add user -u larry, generate random password -g, name this database entry wiki.gentoo.org:

user $keepassxc-cli add Passwords.kdbx -u larry -g wiki.gentoo.org

ls

list database entries:

user $keepassxc-cli ls Passwords.kdbx

show

Show entry name wiki.gentoo.org, show the protected show -s password entry

user $keepassxc-cli show -s Passwords.kdbx wiki.gentoo.org

show (TOTP)

Generate a TOTP, a Time-Based One-Time Password from the the wiki.gentoo.org database entry using the show -t -t token command:

user $keepassxc-cli show -t Passwords.kdbx wiki.gentoo.org

clip

Copy passsword from the wiki.gentoo.org entry name to clipboard. A timer is running at command line output [...] skipped for brevity:

user $keepassxc-cli clip Passwords.kdbx wiki.gentoo.org

The default timer is set to10 seconds. Use the Ctrl+V keys to paste.

rm

Remove the database entry named wiki.gentoo.org:

user $keepassxc-cli rm Passwords.kdbx wiki.gentoo.org

The entry will be moved to the database recycle bin.

generate

keepassxc-cli generate random password, password length -L 64

user $keepassxc-cli generate -L 64
aUVEetihMzbFMeqV4CjxTaWEVJReqXQnEuFqNiL7P4nXCDh57bSbrT7Wfst9XU2H

diceware

keepassxc-cli diceware a phrase using only 4 words -W 4. Default setting is 7:

user $keepassxc-cli diceware -W 4
casing handshake tank overdraft

Use a local wordlist by appending -w example_wordlist.txt at the end of the shown command example. Example wordlist are availble here.

man

For more commands and options use the manual pages:

user $man keepassxc-cli

Invocation

user $keepassxc-cli

Tips

Passwordless authentication

Depending on the given situation it might be useful to authenticate using only a ~/*.keyx file, without the need of keyboard-interactive user authentication. For example, testing in automated environements.

Generate a random key file named keepass.keyx in current directory, generate using openssl:

user $openssl rand -out keepass.keyx 256

Now keepassxc-cli db-create the database, and set keyfile to --set-key-file keepass.keyx, using applications default Passwords.kdbx database name:

user $keepassxc-cli db-create --set-key-file keepass.keyx Passwords.kdbx
Successfully created new database.

Display database technical information using the keepassxc-cli db-info command, use --key-file keepass.keyx to authenticate and ask --no-password:

user $keepassxc-cli db-info Passwords.kdbx --key-file keepass.keyx --no-password

See also

  • KeePassXC — modern, secure, open-source, and cross-platform password manager
  • pass — a command-line password manager that stores, retrieves, generates, and synchronizes passwords securely.
  • Password management tools — This meta article is dedicated to secure password generation, auditing of generated passwords for security, and management of existing passwords.

External resources