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
~/.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_sessionsandroot_key - Windows Credential Manager, as generic credentials named
unkey/cli_sessionsandunkey/root_key - Linux Secret Service, through
secret-tool, with attributeservice=unkeyandaccount=cli_sessionsoraccount=root_key
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
~/.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-toolcommand - A running Secret Service provider with an unlocked default keyring, such as GNOME Keyring, KDE Wallet, or KeePassXC with Secret Service integration turned on
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.