Skip to main content

Secrets Commands (CLI)

Locker Secrets has a command-line interface (CLI) that includes common features and output formatting. The Locker Secrets CLI is a single static binary — a wrapper around the HTTP API.

Installation

The Locker Secrets CLI can be downloaded using the links below:

Locker Secrets Data Schema

There are two types of encrypted data: secret and environment, with each secret belonging to a specific environment (default is the special All environment). The data follows two rules to enforce uniqueness: each environment name must be unique, and each pair (secret key, environment name) must be unique.

CLI Command Structure

Each command is represented as a command or subcommand. Build the CLI command so that command options precede the path and arguments if any:

Credential Priority Order

Typically, a Locker Secrets command must be provided with the access key ID and secret via two flags:
However, if the environment variables LOCKER_ACCESS_KEY_ID and LOCKER_ACCESS_KEY_SECRET are set or the credential data is initialized using configuration, Locker Secret will use them instead:
If more than one credential is provided, Locker Secret will prioritize in the following order: command-line flags → credential file → environment variables.

Global flags

  • --version: get the version information of the Locker Secrets CLI.
  • --help: get CLI help for the current command/subcommand.
  • --output: set this flag to output the result to an output.txt file in the current working directory.

Configuration Command

Set the access key details in the credential file.
There will be an input prompt for any flag not provided. If there is an old access key ID in the credential file, there will be a confirmation prompt to overwrite them.

Secret Command

Perform Read and Write actions on encrypted secrets.

Environment Command

Perform Read and Write actions on encrypted environments.

Common Command Flags

For secret, environment, and scan commands:
  • --output [string]: export output data to a file specified by the path.
  • --output-format: specify the output format (json, env, txt) — default is txt.
For secret and environment commands:
  • --access-key-id [string]: obtained from the Locker Secrets client.
  • --secret-access-key [string]: obtained from the Locker Secrets client.
  • --headers [strings]: custom headers, must be in the format "key1: value1, key2: value2".
  • --credential [string]: path to the credential file, default is $USER/.locker/credential.json.
  • --api-base [string]: set the server API endpoint, default is https://api.locker.io/locker_secrets.
  • --agent [string]: specify the agent. Must be in the format agent - version, accepts Python, .Net, NodeJS, Java.
  • --fetch: force Locker Secrets to fetch data from the cloud server instead of local storage.
  • --json: format the output data as JSON; if --output is set, the file will be renamed to output.json.
  • --dotenv: use with --output, renames the output file to .env.
  • --resttime [int]: set the idle time between API calls.

List Subcommand

Available on secret and environment commands. Fetches and decrypts all items from the server. Optional flag: --environment (for secret) — specifies the related environment, default is null (All environment).

Get Subcommand

Available on secret and environment commands. Fetches and decrypts a specific item from the server. Required flag: --key (for secret) or --name (for environment). Optional flag: --environment (secret only) — default is null.

Create Subcommand

Available on secret and environment commands. Creates an encrypted version of the input data on the server. Required flags: --key, --value (for secret) or --name (for environment). Optional flags: --description, --url, --environment (for secret).

Update Subcommand

Available on secret and environment commands. Modifies the data of a secret or environment. Required flags: --key (for secret) or --name (for environment), and at least one of the --new-* flags. Available --new-* flags: --new-key, --new-value, --new-description, --new-environment (for secret); --new-name, --new-url, --new-description (for environment). Example of a full field update for a secret:
Example of updating only the key: