Files
dotfiles/modules/claude-code/authentication.md
alexion ccc08ff1d8 Add a Claude Code Module and enable it on neogaia (task 0008)
Install Claude Code through home-manager's native programs.claude-code
module, matching how the tmux and fish Modules use their home-manager
options rather than a raw home.packages entry. The feature Module at
modules/claude-code/claude-code.nix stays thin — just the enable option
and the delegation — and writes no settings, so login and first-run
configuration remain interactive and no auth material enters the repo.

Signing in without a browser (needed over the console or SSH) is
documented in modules/claude-code/authentication.md: the paste-code OAuth
flow, where the printed URL is opened on another device and the code
pasted back, and the ANTHROPIC_API_KEY path for non-interactive use.

The neogaia toplevel builds with claude-code-2.1.209 included.
2026-07-19 07:57:43 -04:00

1.7 KiB

Authenticating Claude Code without a browser

neogaia is driven from the console and over SSH, where no local browser can service Claude Code's default OAuth redirect. Either of the two paths below signs the CLI in from a bare terminal. Both are one-time actions per machine; the credentials land under ~/.claude, which home-manager does not overwrite.

Paste-code flow (Claude subscription or Console OAuth)

Run claude and start the login with the /login command (the first run offers it automatically). On a machine with no browser it cannot open the authorization page itself, so it prints the authorization URL and waits.

  1. Copy the printed URL to a browser on any other device (phone, another laptop).
  2. Sign in and approve the request there.
  3. The page returns a short authorization code; paste it back at the claude prompt still waiting in the terminal.

The session then completes and the token is stored, so later runs need no further login. Because the URL is opened on a different device, this works unchanged over SSH.

API key

For non-interactive use, set an Anthropic API key from https://console.anthropic.com in the environment before launching claude:

$ export ANTHROPIC_API_KEY=sk-ant-...
$ claude

Claude Code reads ANTHROPIC_API_KEY on startup and skips the interactive login entirely, so this path needs neither a browser nor the paste-code exchange. Usage is billed to the Console account that owns the key rather than to a Claude subscription.

The key is a secret and is deliberately not baked into this configuration. Export it from the shell for a one-off, or source it from a secret store once one exists on the Host.