GuidesGetting started

Claude Code login: sign in, switch accounts, log out

How to log in to Claude Code: first-run sign-in, /login and /logout, claude auth login and status, signing in over SSH, switching accounts, and API keys.

November 25, 2026The Everpod team
The short answer

Run claude. On first launch it opens a browser to sign in; choose your Claude subscription (Pro, Max, Ultra, Team or Enterprise), an Anthropic Console account for pay-per-token billing, or a cloud provider. From the shell, claude auth login does the same and claude auth status --text shows who you are signed in as. Inside a session, /login signs in and /logout signs out; to switch accounts, run /logout and then sign in with the other one. On a machine with no browser, press c to copy the sign-in link, open it on your laptop or phone, and paste the code it shows at Paste code here if prompted. An ANTHROPIC_API_KEY in your environment wins over a subscription login once you approve it, and /status shows which one a session is using.

Signing in the first time

claude
Copied

Anthropic’s authentication docs say Claude Code “opens a browser window for you to log in on first launch”. Sign in there, and the terminal shows Login successful and asks you to press Enter. If no browser opens, press c to copy the link and paste it into one yourself. If the browser shows a code instead of sending you back, paste the code into the terminal. Which account to pick:

The browser sign-in is skipped when you have already run claude auth login, or when ANTHROPIC_API_KEY is set and you approve the key at the prompt. If you haven’t installed Claude Code yet, installing Claude Code covers that first.

The login commands

WhereCommandWhat it does
In a session
/loginSigns in, or renews a login that is about to expire
In a session
/logoutSigns out and resets first-launch setup
In a session
/statusShows the account and which credential is in use
Shell
claude auth loginSigns in without starting a session
Shell
claude auth logoutSigns out
Shell
claude auth statusPrints the sign-in state as JSON; exit 0 signed in, 1 not
Shell
claude setup-tokenPrints a one-year token for scripts and CI

claude auth login takes three flags, per the CLI reference:

claude auth login --email you@example.com   # pre-fill the email address
claude auth login --sso                     # force SSO
claude auth login --console                 # Console, for API billing instead of a plan
Copied

claude auth status prints JSON whose authMethod is one of none, claude.ai, oauth_token, api_key, api_key_helper or third_party, plus a configDirectory field naming the folder it read. Add --text for a version meant for people. Because it exits 1 when nothing is signed in, a script can check it before calling claude -p.

Signing in over SSH, in WSL or in a container

The browser can’t reach a remote machine, so the sign-in ends with a code you carry back by hand. From Anthropic’s troubleshooting page:

  1. Run claude (or claude auth login) on the machine. At the login prompt, press c to copy the link, which also works when it wraps across lines in a narrow SSH terminal; claude auth login prints it.
  2. Open the link in a browser on your laptop or phone and sign in to the account the machine should use. The browser shows a code instead of returning to localhost.
  3. Paste the code at the prompt that starts Paste code here.

If pasting into the full-screen prompt does nothing, try your terminal’s other paste shortcut (right-click or Shift+Insert in Windows Terminal), or use claude auth login, which reads the code from standard input. That doesn't look like the full code means part of it was lost: copy all of it, including the # in the middle. OAuth error: Invalid code means the code expired or was cut off; start again and paste it promptly. On WSL2 you can point Claude Code at your Windows browser for next time:

export BROWSER="/mnt/c/Program Files/Google/Chrome/Application/chrome.exe"
claude
Copied

That sign-in lasts until it expires and then has to be done again in a terminal. For a job with nobody present, a CI pipeline or a cron script, claude setup-token runs the same sign-in once and prints a one-year token for CLAUDE_CODE_OAUTH_TOKEN. It needs a Pro, Max, Ultra, Team or Enterprise plan and can only make model requests.

Switching accounts, or using two

To move from one account to another, such as from a personal plan to your company’s Team account, sign out and sign in again:

/logout      # inside Claude Code, or: claude auth logout
claude       # start again and sign in with the other account
Copied

/logout resets first-launch setup, so the next claude walks you through sign-in and setup again. It removes more than the Claude login: the troubleshooting page says logging out removes “all stored credentials, including the plaintext file’s contents, saved MCP server logins, and plugin sensitive values”, so expect to re-authorize MCP servers and re-enter plugin secrets.

To stay signed in to both, give each account its own configuration folder with CLAUDE_CONFIG_DIR. Each folder has its own settings, session history and login. The docs’ example, for ~/.bashrc or ~/.zshrc:

alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude'
Copied

Open a new terminal and run claude-work; it signs in separately, and claude keeps your personal account. One exception: two Console sign-ins made without an API key aren’t kept apart this way, because Claude Code stores that kind of sign-in outside the configuration folder.

A work organization can decide which account you may use. If an admin requires logins from their organization, Claude Code keeps showing the login prompt until you sign in with an account in it, and refuses others. On Enterprise, the sign-in page can answer Authorization failed with “Claude Code access has not been granted for this account. Contact your administrator.”, which only an Owner can fix by giving you a role that includes Claude Code.

Where the login is stored

SystemLocation
macOS
The macOS Keychain, encrypted
Linux
~/.claude/.credentials.json, mode 0600
Windows
%USERPROFILE%\.claude\.credentials.json

On a Mac signed in over SSH, the Keychain can be locked, and Claude Code then writes the login to ~/.claude/.credentials.json instead, as on Linux. To move it back, the troubleshooting page has you run claude doctor, unlock the Keychain if it reports macOS Keychain is not writable, then /logout and /login:

security unlock-keychain ~/Library/Keychains/login.keychain-db
Copied

With CLAUDE_CONFIG_DIR set, the file lives in that folder instead, and on macOS the Keychain entry is tied to it too. That is why a cron job, a sudo command or a service running as another user can find no login even though you are signed in: “Not logged in” in Claude Code walks through it. The file is your live login, so keep it out of repositories and shared backups; Anthropic’s docs say Claude Code manages it through /login and /logout, so don’t edit it.

Which credential wins

A machine can hold a subscription login and an API key at once. When it does, the authentication precedence decides, in this order, as of November 25, 2026:

  1. Cloud provider credentials, when CLAUDE_CODE_USE_BEDROCK, CLAUDE_CODE_USE_VERTEX or CLAUDE_CODE_USE_FOUNDRY is set
  2. ANTHROPIC_AUTH_TOKEN, for an LLM gateway or proxy
  3. ANTHROPIC_API_KEY, a key from the Claude Console
  4. An apiKeyHelper script’s output
  5. CLAUDE_CODE_OAUTH_TOKEN, from claude setup-token
  6. Anthropic profile and federation credentials (a profile written by ant auth login ranks here only when ANTHROPIC_PROFILE names it, and otherwise below /login)
  7. “Subscription OAuth credentials from /login. This is the default for Claude Pro, Max, Ultra, Team, and Enterprise users.”

So a subscription login made with /login comes last. With ANTHROPIC_API_KEY set, an interactive session asks once whether to use it and remembers the answer (change it later with the “Use custom API key” toggle in /config); in claude -p “the key is always used when present.” A forgotten key from an old job or project, still exported in your shell profile, is the usual reason a working subscription fails with an error like:

API Error: 400 ... "This organization has been disabled"
Copied

Drop the key and check:

unset ANTHROPIC_API_KEY
claude
# then, in the session:
/status
Copied

Remove the export ANTHROPIC_API_KEY= line from ~/.zshrc, ~/.bashrc or ~/.profile to make it stick (on Windows, check $PROFILE and your user environment variables). When a login and a key are both configured, /status marks the one that isn’t in use. The same order applies to a CLAUDE_CODE_OAUTH_TOKEN exported in your profile: it outranks /login in every new session until you remove it. Cloud sessions on claude.ai are the exception and always use your subscription.

When the login expires

A subscription login doesn’t last forever, and using Claude Code doesn’t extend it. On 2.1.318 or later, claude auth status --text prints a line such as:

Sign-in ends: between 2026-11-20 and 2026-11-23 (2026-11-23T17:04:11.000Z)
Copied

Sign in again with /login or claude auth login before the earlier date, and at once if it says any day now or may have ended. From that date Claude Code warns at startup with Your login expires in 3 days · run /login to renew, and once it has lapsed, /status shows a Login row reading Expired — log in again.

When signing in fails

When the cause isn’t clear, Anthropic’s reset is to run /logout, close Claude Code, start claude again and sign in from scratch.

Run Claude Code on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.