Command-line interface for Password Safe.
$ dotnet add package PasswordSafe.Clipwsafe is a .NET global tool that provides a command-line interface for working with Password Safe (.psafe3) databases.
From the packaged tool:
dotnet tool install -g PasswordSafe.CliOr from source:
dotnet pack -c Releasedotnet tool install -g --add-source ./nupkg PasswordSafe.CliInitialize configuration:
pwsafe config initThe config file is created under your home directory:
%HOMEDRIVE%%HOMEPATH%\.pwsafe\config.json$HOME/.pwsafe/config.jsonYou can override the home directory (useful for automation/tests) by setting:
PWSAFE_HOME (Windows/Linux/macOS)--no-color: Disable ANSI colors (useful for logs/CI).--debug: Show full exception stack traces (default is a short error message).Start an interactive session (prompts once for the database password, then you can run any existing subcommands):
pwsafe interactivepwsafe interactive -a vaultpwsafe interactive -f C:\path\to\vault.psafe3The session exits automatically after idleTime minutes of no input (configured via pwsafe config set --idle-time).
Most commands that open a database support non-interactive password input:
--password-stdin: Read the password from stdin--password-env <VAR>: Read the password from an environment variableExample:
set PWSAFE_PASSWORD=CorrectHorseBatteryStaple!pwsafe db show -a vault --password-env PWSAFE_PASSWORDCreate an empty database and register it:
pwsafe db create C:\path\to\vault.psafe3 -a vault -dAdd an existing database:
pwsafe db add -a vault -f C:\path\to\vault.psafe3List databases:
pwsafe db listSet default database:
pwsafe db set -a vaultShow database info (defaults to the configured default db if no args are provided):
pwsafe db showpwsafe db show -a vaultpwsafe db show -f C:\path\to\vault.psafe3Scripting output (some commands):
--json: Output machine-readable JSON--quiet: Suppress non-essential outputList entries:
pwsafe entry list (uses default db)pwsafe entry list -a vaultpwsafe entry list -f C:\path\to\vault.psafe3Create an entry:
pwsafe entry new -a vault -t "GitHub" -u "me" -p "secret" --url "https://github.com"If --password is omitted, a password will be generated using the provided options:
pwsafe entry new -t "Example" --min-length 16 --max-length 24 --digits --uppercase --lowercase --specialShow entry details:
pwsafe entry show <ID> -a vaultCopy entry password to clipboard:
pwsafe entry get <ID> -a vaultClipboard safety options (entry get and policy genpass):
--print: Print password to stdout (no clipboard)--no-clipboard: Do not copy to clipboard--clear-after <SECONDS>: Clear clipboard after N seconds (requires clipboard copy)Update an entry:
pwsafe entry update <ID> -a vault --url "https://example.com"Remove an entry:
pwsafe entry remove <ID> -a vaultRenew an entry password (uses the entry's stored policy):
pwsafe entry renew <ID> -a vaultList policies:
pwsafe policy list -a vaultAdd/update/remove a policy:
pwsafe policy add -a vault -n "Default Policy" --length 20 -d 2 -u 2 -l 2 -s 2pwsafe policy update -a vault -n "Default Policy" --length 24 -d 2 -u 2 -l 2 -s 2pwsafe policy rm -a vault "Default Policy"Generate a password using a named policy:
pwsafe policy genpass -a vault -n "Default Policy"--password-stdin / --password-env).entry get copies the password to the clipboard by default.