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.

Before you start
- Retrieve the key from an approved secret manager at runtime.
- Use a private
XDG_CONFIG_HOMEwhen saving it; config directories and files should remain 0700 and 0600. config getredacts the key. Do not build workflows that try to read it back.
Steps
- Load the secret into a transient environment variable without echoing it. Disable command tracing around the retrieval and CLI invocation.
- For one command, export
DOSYA_API_KEYonly to that process. For saved authentication, pipe the secret to the supported key-from-stdin form using--key -. - Run
dosya whoami --jsonand validate the expected identity. Capture stdout and stderr without printing the environment. - Unset the shell variable immediately after the process. Ensure job logs, crash reports, and debug wrappers do not dump the environment.
- Use local logout when only the machine’s saved credential should be removed. Use
logout --revokewhen the server key must also be invalidated. - 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.

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.
Related guides
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.