Login, Logout, Whoami
Three commands defined incmd/crewship/cmd_login.go cover every way the CLI authenticates against a Crewship server. The token lands in ~/.crewship/cli-config.yaml (or the selected profile); subsequent commands pick it up from there. Login and the other top-level commands respect the global --server and --profile flags. --workspace is a global context flag for workspace-scoped commands; login does not select a workspace.
crewship login
Three supported modes — interactive credentials, token, or device-code pairing. Interactive is the default when no mode flag is set. The legacy --google flag is unavailable and exits locally with an error.
Interactive
/api/auth/callback/credentials → session cookie → POST /api/v1/auth/cli-token to mint a permanent CLI token; falls back to the session token if the CLI-token endpoint isn’t available on an older server).
Guest accounts use the same password login or browser token flow. Their CLI
token retains current Guest grants. Creating another token requires an
interactive session; a Guest bearer cannot remint a wider successor.
Token
Google sign-in is unavailable
Google OAuth redirect and callback routes are deliberately disabled in the Crewship server, even when Google client credentials remain configured.crewship login --google therefore fails locally. Use the email/password,
token, or pairing modes documented here instead; this flag does not open a
browser or exchange credentials.
Device-code pairing
Non-interactive (systemd / CI / test harnesses)
The default email+password flow prompts for the password viaterm.ReadPassword,
which requires a real TTY and fails outright over a pipe:
--email plus one of two password sources removes the TTY dependency entirely
— useful for a systemd timer re-authenticating after a dev-slot reseed, a CI
job, or a headless test harness:
--password-stdin when both work (preferred for CI / scripts — avoids
argv leak): an environment variable is readable from /proc/<pid>/environ by
anything running as the same user and is inherited by every child process, so
on shared machines CREWSHIP_PASSWORD exposes the password more broadly than
a stdin pipe does. Reserve the env var for runners that can only inject
secrets through the environment.
Both go through the same CSRF+credentials exchange and CLI-token mint as
interactive login, so the persisted token behaves identically. Passing both
--password-stdin and CREWSHIP_PASSWORD is refused (mutually exclusive)
rather than silently picking one.
Targeting a profile
Pass--profile <name> (or set CREWSHIP_PROFILE) to authenticate a named
server profile instead of the top-level config. The minted token
is stored inside that profile. If no default profile is set yet, that
profile also becomes current (logging into another profile later does not
re-point an existing default):
--profile/CREWSHIP_PROFILE, login writes the legacy top-level
server/token fields exactly as before. logout is profile-aware too: it
clears the active profile’s token and leaves sibling profiles signed in.
Common errors
pair: the pair code didn't work — codes expire after 10 minutes— codes have a 10-min TTL. The server intentionally folds wrong code / expired / already consumed into one message to avoid being an enumeration oracle; the most likely cause is the TTL.Google sign-in is unavailable— Google sign-in is disabled. Use email/password,--token, or--pair; setting Google client credentials does not enable the removed flow.refusing to overwrite a malformed file — fix or remove ~/.crewship/cli-config.yaml and retry— the config file exists but isn’t valid YAML. Surfaced explicitly so the CLI doesn’t silently wipe your saved server/workspace.--password-stdin and CREWSHIP_PASSWORD are mutually exclusive— both non-interactive password sources were set; drop one.--password-stdin: no password on stdin—--password-stdinwas passed but stdin had no content (or only whitespace).
crewship logout
token field in ~/.crewship/cli-config.yaml. Leaves server and workspace alone so the next crewship login re-uses the same profile without retyping the URL. The token is not revoked on the server — to do that, delete it from Settings → CLI tokens in the web UI (DELETE /api/v1/auth/cli-tokens/{tokenId}).
crewship whoami
GET /api/v1/workspaces plus GET /api/v1/auth/cli-token/validate to print the email, server URL, currently selected workspace (if any), and your role in it. The Server: line shows the effective server the command actually dialed — it honours the active profile (--profile / CREWSHIP_PROFILE) with the usual precedence (--server → profile → CREWSHIP_SERVER env → config), so it is the authoritative answer to “which instance am I talking to?”. Useful as a CI smoke check (crewship whoami || exit 1) before running a real mutation.
See also
crewship setup— interactive crew bootstrap right after pairing.- Authentication guide — the full identity / session / pairing story.
- Admin CLI —
crewship admin reset-passwordfor the locked-out-of-UI case.