Skip to main content
unkey login starts a device login. You confirm the code in the dashboard, choose what the CLI can do, and the CLI stores a session. Humans use unkey login. CI uses a root key. unkey auth login runs the same command.

Usage

The command writes a confirmation code and a URL to stderr. In a terminal, it asks whether to open the URL in your browser, with Continue without opening a browser selected by default. Open the URL yourself or select Open browser. Instructions and waiting messages also go to stderr. Sign in, check that the code matches the terminal, and choose what the CLI can do. Click Authorize CLI. The CLI finishes from that approval. Only authorize a login you started yourself. Anyone who gets you to approve their code receives a CLI session, so deny any code that someone sent you. The CLI keeps polling until the login finishes or expires. On success it stores one session for that workspace in the system keychain, or in ~/.unkey/sessions.json with mode 0600 when the keychain is unavailable. In that case it also prints a warning to stderr. It prints only Signed in. to stdout, without tokens or the workspace ID. unkey logout revokes the session. unkey workspace switch changes the active workspace. A denied or expired login stops with the reason. Run unkey login again to start over. The CLI retries network errors and server errors while it waits. If the CLI receives a session but cannot store it, it attempts to revoke that session on the server and exits with an error. The error confirms revocation only if it succeeded. Run unkey login again once the keychain or ~/.unkey is writable. Starting and polling logins is rate limited per IP address. When you hit the limit, the API answers ip_rate_limited.

Flags

string
default:"https://api.unkey.com"
API origin to call. Falls back to UNKEY_API_BASE_URL. Defaults to https://api.unkey.com.
boolean
Print the verification URL without asking whether to open a browser.
string
Store a root key and skip the browser. Pass - to read the key from stdin, with a hidden prompt when stdin is a terminal, so the key stays out of your shell history and process list. The command does not check the key with the API, and it does not read UNKEY_ROOT_KEY.

Where credentials are stored

unkey login stores a CLI session, and unkey login --root-key stores a root key. The CLI keeps both in the operating system secret store, under service unkey:
  • macOS Keychain, as generic passwords with accounts cli_sessions and root_key
  • Windows Credential Manager, as generic credentials named unkey/cli_sessions and unkey/root_key
  • Linux Secret Service, through secret-tool, with attribute service=unkey and account=cli_sessions or account=root_key
On macOS, the CLI passes secrets to the security tool on stdin, so they do not appear in the process list, and reads them back to confirm the save. If the secret store is unavailable, the CLI writes a file in ~/.unkey instead. Only your user can read the file (mode 0600, in a 0700 directory), but the secret in it is not encrypted. When this happens, the CLI prints a warning with the file path to stderr. Neither command prints the secret. The root key file looks like this:
~/.unkey/config.toml
When the secret store works again, the CLI moves a file it finds there into the store and removes the file. A root key in ~/.unkey/config.toml replaces any older key in the secret store, because the file only holds a key when the last save could not reach the secret store. --config or UNKEY_CONFIG pointing at a different file is read as a file and is not copied into the keychain. Running unkey login --root-key again replaces the stored key. The session has exactly the permissions you selected. It does not inherit every permission your user has. Any role can approve a login, limited to the permissions that role can grant. Resource commands and unkey deploy use a stored CLI session when neither --root-key nor UNKEY_ROOT_KEY is set, and the session’s API URL matches the command. An explicit --config on a resource command is used instead of the session. A root key saved with --root-key is the next fallback. See CLI authentication.

Use the secret store on Linux

On Linux, the CLI uses the secret store only when both of these are present:
  • The secret-tool command
  • A running Secret Service provider with an unlocked default keyring, such as GNOME Keyring, KDE Wallet, or KeePassXC with Secret Service integration turned on
Install secret-tool, and GNOME Keyring if you have no provider, with your package manager: GNOME and KDE desktops start a provider and unlock it when you log in. With a standalone window manager or over SSH, nothing unlocks it. To unlock GNOME Keyring with your login password there, add pam_gnome_keyring.so to your PAM login configuration as described in the GNOME Keyring PAM setup. If secret-tool fails for any reason, the CLI uses the files in ~/.unkey instead.

Examples

Sign in, then call the API without a key flag:
Sign in on a machine without a browser:
Store a key you already created. The CLI prompts for it without echoing:
Store a key from a script or secret manager:
Point the command at a local API:
Last modified on November 4, 2026