unifi login
About 900 words
Sign in to a UniFi console and create a context for it.
Usage
unifi login [flags]Sign in to a UniFi console and create a context for it.
Run without flags on a terminal, unifi login walks you through it: it explains how to create an API key, checks the key, lets you pick the console and the default site, and stores the key in your OS keychain (or, on machines without one, in a credentials file only you can read). The key is never written to the configuration file.
There are three ways to sign in:
Cloud (default) A Site Manager API key, created at https://unifi.ui.com under
Settings → API Keys. Reaches every console of your UI account
through the cloud, from anywhere.
--local An API key created on one console (Settings → Control Plane →
Integrations). Talks to the console directly on your network.
--sso EXPERIMENTAL. Your UI account's e-mail, password and one-time
code. Creates a Site Manager API key for you and continues as
the cloud sign-in. The key is named after this machine and
valid for --key-expiration (one year by default). Sign-in and
key creation both use undocumented endpoints of the UI account
service and may stop working. The password is never stored.
The session of the sign-in is stored next to the key, in the
credential store, so that `unifi logout` can revoke the key;
--no-store-session leaves it out, and logout then asks you to
sign in again.A console with its factory certificate is not trusted by your machine. With --local, unifi login then shows the certificate's SHA-256 fingerprint and offers to pin it: the certificate is saved next to the configuration and only that certificate is trusted for this controller from then on, so a different one later is an error. Compare the fingerprint with the one the console shows. Scripts pass --pin-certificate. Skipping verification with --insecure-skip-tls-verify remains possible and is the weaker choice.
Scripts and agents sign in without a terminal by passing everything as flags. The API key is read from --api-key-stdin, from the UNIFI_API_KEY environment variable or from --api-key, in that order of preference. Avoid --api-key: a command-line argument is visible to every user of the machine in the process list and is written to your shell history.
Examples
# Interactive sign-in through unifi.ui.com
unifi login
# A console on the local network with its factory certificate
unifi login --local --address https://192.168.1.1 --pin-certificate
# Non-interactive: key on standard input, console and site as flags
unifi login --api-key-stdin --console "Dream Machine" --site Default --name home < key.txt
# One context per console of the account
UNIFI_API_KEY=... unifi login --all-consoles
# Experimental: sign in with e-mail and password
unifi login --sso --username [email protected]
# Experimental, non-interactive, with a key that expires after three months
unifi login --sso --username [email protected] --password-stdin \
--one-time-code 123456 --key-expiration 3m < password.txtFlags
| Flag | Description |
|---|---|
--address <string> | address of the local controller, such as https://unifi.local |
--all-consoles | create one context for every console of the account |
--api-key <string> | API key; it shows in the process list and the shell history, so prefer --api-key-stdin or UNIFI_API_KEY |
--api-key-stdin | read the API key from standard input |
--ca-file <string> | PEM file with the self-signed certificate of a controller, or its authority (not for unifi.ui.com) |
--console <string> | console to sign in to, by name or ID |
--insecure-skip-tls-verify | do not verify the TLS certificate of a controller that uses a self-signed one (not for unifi.ui.com) |
--key-expiration <string> | how long the API key created by --sso stays valid: 1m, 3m, 6m, 1y, 3y, never (default 1y) |
--local | sign in to one controller on the local network |
--name <string> | name of the context to create or replace (default: derived from the console) |
--no-browser | do not offer to open the API keys page in the browser |
--no-store-session | with --sso, do not keep the UI session that lets unifi logout revoke the created key |
--no-switch | keep the current context instead of switching to the new one |
--one-time-code <string> | current code of the authenticator app, for --sso |
--password-stdin | read the UI account's password from standard input, for --sso |
--pin-certificate | trust exactly the certificate the local controller presents now, when it is not trusted otherwise |
--replace-key | with --sso, delete the account's key of the same name instead of creating a numbered one |
-s, --site <string> | default site of the new context; without it, a terminal sign-in asks when the console has several |
--sso | EXPERIMENTAL: sign in with the UI account's e-mail and password |
--username <string> | e-mail address of the UI account, for --sso |
Global flags
These flags are accepted by every command.
| Flag | Description |
|---|---|
--color-scheme <string> | color scheme: auto, dark or light |
--context <string> | context to use instead of the current one |
--no-cache | ask the controller for everything instead of using cached answers |
-o, --output <string> | output format: text, wide, json, yaml (table is another name for text) |
-s, --site <string> | site to act on instead of the context's default site |
--theme <string> | theme to render with instead of the configured one |
