How to use the command keepassxc-cli (with examples)

How to use the command keepassxc-cli (with examples)

The keepassxc-cli command-line interface is a powerful tool for managing KeepassXC databases. It allows users to search for entries, list folder contents, add and delete entries, and copy passwords and TOTP codes to the clipboard. Additionally, it can generate passphrases and passwords with specific requirements.

Use case 1: Search entries

Code:

keepassxc-cli search path/to/database_file name

Motivation: Searching for entries in a KeepassXC database is essential for quickly finding the required information. By using the keepassxc-cli search command, users can easily locate entries based on the entry’s name.

Explanation:

  • path/to/database_file: Specifies the path to the KeepassXC database file.
  • name: Specifies the name of the entry to search for.

Example output:

Entry found: 
 - Name: Example Entry
 - Path: Example/Entry
 - UUID: 234b2e61-15e5-4a85-95d0-c190921e1350

Use case 2: List the contents of a folder

Code:

keepassxc-cli ls path/to/database_file /path/to/directory

Motivation: Sometimes, it is necessary to get an overview of the contents of a specific folder in a KeepassXC database. The keepassxc-cli ls command enables users to list all entries within a given folder.

Explanation:

  • path/to/database_file: Specifies the path to the KeepassXC database file.
  • /path/to/directory: Specifies the path to the folder to be listed.

Example output:

Listing folder: /Example/Folder

- Example Entry 1
- Example Entry 2
- Example Entry 3

Use case 3: Add an entry with an auto-generated password

Code:

keepassxc-cli add --generate path/to/database_file entry_name

Motivation: When creating a new entry in a KeepassXC database, it can be convenient to have an auto-generated password. With the keepassxc-cli add command, users can easily add a new entry with a password generated by the tool.

Explanation:

  • path/to/database_file: Specifies the path to the KeepassXC database file.
  • entry_name: Specifies the name of the new entry.

Example output:

Entry 'New Entry' created with an auto-generated password:
 - Password: eR27xS3p

Use case 4: Delete an entry

Code:

keepassxc-cli rm path/to/database_file entry_name

Motivation: Deleting unnecessary entries from a KeepassXC database helps maintain a clean and organized password database. The keepassxc-cli rm command allows users to easily remove an entry from the database.

Explanation:

  • path/to/database_file: Specifies the path to the KeepassXC database file.
  • entry_name: Specifies the name of the entry to be deleted.

Example output:

Entry 'Old Entry' deleted successfully.

Use case 5: Copy an entry’s password to the clipboard

Code:

keepassxc-cli clip path/to/database_file entry_name

Motivation: Copying passwords to the clipboard is often required for logging into different accounts or systems. The keepassxc-cli clip command enables users to quickly copy the password of a specific entry to the clipboard.

Explanation:

  • path/to/database_file: Specifies the path to the KeepassXC database file.
  • entry_name: Specifies the name of the entry whose password should be copied.

Example output:

Password for 'Example Entry': Copied to clipboard.

Use case 6: Copy a TOTP code to the clipboard

Code:

keepassxc-cli clip --totp path/to/database_file entry_name

Motivation: When using time-based one-time passwords (TOTP), it is crucial to have easy access to the code. The keepassxc-cli clip command with the –totp flag allows users to copy a TOTP code to the clipboard.

Explanation:

  • path/to/database_file: Specifies the path to the KeepassXC database file.
  • entry_name: Specifies the name of the entry containing the TOTP key.

Example output:

TOTP code for 'TOTP Entry': Copied to clipboard.

Use case 7: Generate a passphrase with 7 words

Code:

keepassxc-cli diceware --words 7

Motivation: A strong passphrase is essential for secure access to sensitive information. The keepassxc-cli diceware command generates a random passphrase using the Diceware method.

Explanation:

  • --words 7: Specifies the number of words in the passphrase (in this case, 7 words).

Example output:

Generated passphrase: correct horse battery staple paper clip dream of sugar

Use case 8: Generate a password with 16 printable ASCII characters

Code:

keepassxc-cli generate --lower --upper --numeric --special --length 16

Motivation: Creating secure passwords that meet various requirements can be time-consuming. The keepassxc-cli generate command makes it easy to generate strong, random passwords.

Explanation:

  • --lower: Includes lowercase letters in the password.
  • --upper: Includes uppercase letters in the password.
  • --numeric: Includes numeric digits in the password.
  • --special: Includes special characters in the password.
  • --length 16: Specifies the length of the password (in this case, 16 characters).

Example output:

Generated password: t5gH!2Y*Qv$u8b#z

Conclusion:

The keepassxc-cli command-line interface provides a wide range of functionality for managing KeepassXC databases. With its ability to search, list, add, delete, and copy passwords, as well as generate passphrases and passwords, this tool is an invaluable asset for anyone working with KeepassXC.

Related Posts

How to use the command 'fisher' (with examples)

How to use the command 'fisher' (with examples)

Fisher is a fish-shell plugin manager that allows users to easily install, update, and remove plugins for their fish shell.

Read More
How to Use the Command `makepkg` (with examples)

How to Use the Command `makepkg` (with examples)

Makepkg is a command used in Arch Linux to create packages that can be used with the pacman package manager.

Read More
How to Use mate-screenshot (with examples)

How to Use mate-screenshot (with examples)

mate-screenshot is a command-line tool that allows you to capture screenshots in the MATE desktop environment.

Read More