Safeguard Docs
Credentials Vault

Run a command with vault secrets

Reference for safeguard vault exec, which runs a command with vault secrets set as environment variables and never prints them. Coming soon.

Run a command with vault secrets

Coming soon. safeguard vault exec is not released yet. This page records the planned behavior and will be updated with the final flags when it ships.

safeguard vault exec checks a credential out of the vault, starts your command with the value in its environment, and checks the credential back in when the command ends. The value is never printed, never placed on the command line and never written to a log.

Planned shape

safeguard vault exec --env PGPASSWORD=sgvault://prod-pg -- psql -c 'select 1'
FlagMeaning
--env NAME=refSet an environment variable from a vault reference. Repeat for more
--redact-outputReplace any secret value in the command's output with [redacted]

Planned behavior

  • You need the USE grant on the credential. Without it the command does not start and the exit code is 3 with NOT_GRANTED.
  • The lease is checked in when the command exits, when you press Ctrl-C and when the command crashes.
  • Other users on the machine cannot see the value in the process list, because it is not on the command line.
  • When your organization asks for an MFA confirmation, you enter your authenticator code in the terminal once for the run. A person running the command behind a wrapper that has no terminal can set SAFEGUARD_STEP_UP_CODE to a current code. It is not for CI: in CI, use a credential with an access policy and a USE grant, or agent-token mode.

On this page