Skip to main content

CLI authentication

Store your root key locally so the Unkey CLI authenticates automatically. Configure credentials once and run commands without manual tokens.
1 min read

The unkey auth login command stores your root key in a local config file so you don't have to pass --root-key on every CLI invocation.

Prerequisites#

Installation#

Install the CLI with npm:

Or run it directly with npx:

Log in#

Run the auth login command and paste your root key when prompted:

The key is read as hidden input, it won't be displayed in your terminal.

How it works#

Your root key is saved to ~/.unkey/config.toml. Once stored, other CLI commands (like unkey deploy) use it automatically instead of requiring a --root-key flag.

~/.unkey/config.toml
Warning

The config file stores your root key in plain text. Make sure ~/.unkey/config.toml is not committed to version control or shared.

Best practices#

  • Use a dedicated root key for the CLI: create a separate key with only the permissions your CLI workflows need. See root key permissions for guidance.
  • Don't commit the config file: add ~/.unkey/ to your global gitignore or verify it's excluded from your project repositories.
  • Rotate periodically: run unkey auth login again with a new key to replace the stored one.

Next steps#