Manage secrets from the command line | Pathfinder
A workflow for Workload Credentials on BeyondTrust Pathfinder
When two people or scripts update the same secret at the same time, one change can silently overwrite the other. A lost database password or API key can break services until someone notices. This workflow shows you how to manage secrets from the Workload Credentials command line interface (CLI) and make updates that can't overwrite someone else's change.
Scope of this guide
This guide covers downloading the CLI, logging in, and updating a static secret safely with check-and-set. Check-and-set means the update only goes through if the secret hasn't changed since you last read it. This guide does not cover dynamic secrets or integrations from the CLI.
Prerequisites
- You have a Workload Credentials role assigned to your group in the BeyondTrust Pathfinder platform.
- You have permission to read and update the secret you want to change.
- At least one static secret exists, for example at the path
/prod/db. - You have a terminal on Windows, macOS, or Linux.
Steps
Step 1: Download the CLI and log in
- In Pathfinder, select Menu > Workload Credentials.
- Select Resources > Download CLI.
- In the Download CLI Tool dialog box, select a Version and your Operating system and architecture.
- Select Download.
- In the header, open your user profile and create a personal access token for Workload Credentials. Copy the token.
- Open a terminal and go to the folder that contains the CLI file.
- Run the login command for your operating system, and enter your token when prompted:
- macOS and Linux:
./wlc login - Windows:
wlc.exe login
- macOS and Linux:
The CLI stores your token in a folder under
$HOMEand uses it for later requests. To remove the stored token, runwlc logout.
Step 2: Read and update a secret safely
The examples in this step use wlc. On macOS and Linux, use ./wlc. On Windows, use wlc.exe.
-
Read the secret, and note its version number in the metadata:
wlc static get /prod/db --format json -
Update the secret only if it's still at that version. Replace
5with the version you noted:wlc static update /prod/db -e password=<new-value> --cas 5 -
If the secret changed after you read it, the command fails with this message:
check-and-set parameter did not match the current versionRead the secret again to get the new version, check what changed, then repeat the update with the new version.
ImportantIf you leave out
--cas, the update overwrites the secret even if someone else changed it. Always use--caswhen other people or scripts might update the same secret. To work with a specific site, add--site-id <site-id>to the command.
When the check fails, the command exits with a non-zero code. Scripts can use this to detect the conflict, read the secret again, and retry.
Verify the results
Run wlc static get /prod/db --format json again. Confirm that the secret shows your new value and that its version number went up.
Next steps
- Let pipelines use the CLI without a personal token by setting up workload identities.
- Control who can read and update secrets with role-based access control (RBAC) policies. For more information, see RBAC policies in Workload Credentials.
Related resources
Updated 6 days ago