Pass a CLI credential without printing it

Supply a Dosya API key through stdin or a secret environment variable, retain private file modes, and revoke stored credentials without logging them.

Last reviewed

Dosya API keys begin with dos_. Avoid literal secret arguments because process listings and shell history can expose them; the CLI warns when a key is passed directly on the command line.

Four workflow panels show loading the key privately, passing it outside argv, clearing the transient secret, and choosing local logout or server revocation.
The diagram covers loading the key privately, passing it outside argv, clearing the transient secret, and choosing local logout or server revocation. Open full-size screenshot.

Before you start

  • Retrieve the key from an approved secret manager at runtime.
  • Use a private XDG_CONFIG_HOME when saving it; config directories and files should remain 0700 and 0600.
  • config get redacts the key. Do not build workflows that try to read it back.

Steps

  1. Load the secret into a transient environment variable without echoing it. Disable command tracing around the retrieval and CLI invocation.
  2. For one command, export DOSYA_API_KEY only to that process. For saved authentication, pipe the secret to the supported key-from-stdin form using --key -.
  3. Run dosya whoami --json and validate the expected identity. Capture stdout and stderr without printing the environment.
  4. Unset the shell variable immediately after the process. Ensure job logs, crash reports, and debug wrappers do not dump the environment.
  5. Use local logout when only the machine’s saved credential should be removed. Use logout --revoke when the server key must also be invalidated.
  6. Check the revoke result: a failed server revoke retains the local key so it can be retried, while a 401 clears an already unusable local credential. Verify config output remains redacted.
Dosya CLI overview with installation and command references for pass a cli credential without printing it.
The CLI overview supplies the installation and command references used by “Pass a CLI credential without printing it”. Open full-size screenshot.

Expected result

The CLI authenticates without placing the key in argv or logs, its stored file remains private, and logout behavior matches the chosen local-only or server-revoke intent.

Troubleshooting

The CLI warns about a literal key. Rotate the exposed credential and switch to stdin or a secret environment injection.

Revoke fails with a network error. The local key remains so the server action can be retried; protect the config file until then.

A CI log contains environment output. Remove environment-dump steps and rotate the key. Redaction in config get cannot sanitize unrelated logging tools.

Was this helpful?

Loading helpfulness results…

Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.

Questions and replies

Ask about the steps in this guide. Questions are reviewed before publication.

Keep account details, credentials and private files out of public questions. Use private support for those.

Loading questions…

    Sign in to your Dosya account to ask a question.

    Check the outcome before you retry

    Use these shared checks when a task needs a second look.