Claude Code VPS Authentication — Setup Guide
Claude Code VPS Authentication
Section titled “Claude Code VPS Authentication”The Problem
Section titled “The Problem”Claude Code on the VPS (46.224.129.16) can’t authenticate via the normal OAuth login flow because Cloudflare’s bot protection on claude.ai blocks requests from datacenter IPs. The claude login and claude setup-token commands always time out on the VPS.
The Solution
Section titled “The Solution”Generate a long-lived token (valid for 1 year) on your Mac using claude setup-token, then set it as an environment variable on the VPS. This is a one-time setup per year.
The token is already configured for both patrick and asia users on the VPS (set up 2026-03-11, expires ~2027-03-11).
If the Token Expires (annual renewal)
Section titled “If the Token Expires (annual renewal)”Run these steps from any Mac that has Claude Code installed and logged in:
Step 1: Generate a new token on your Mac
Section titled “Step 1: Generate a new token on your Mac”Open Terminal and run:
claude setup-tokenIt will open a browser, you authenticate, and it gives you a token starting with sk-ant-oat01-.... Copy the full token.
Step 2: Set it on the VPS
Section titled “Step 2: Set it on the VPS”SSH into the VPS and replace the token in .bashrc for both users:
# For patrickssh patrick@46.224.129.16# Edit ~/.bashrc — find the CLAUDE_CODE_OAUTH_TOKEN line and replace the token value# Then: source ~/.bashrc
# For asiassh patrick@46.224.129.16sudo nano /home/asia/.bashrc# Find the CLAUDE_CODE_OAUTH_TOKEN line and replace the token valueStep 3: Verify
Section titled “Step 3: Verify”ssh patrick@46.224.129.16 'PATH=$HOME/.local/bin:$PATH claude --print "say hello"'Important Notes
Section titled “Important Notes”- Do NOT attempt
claude loginorclaude setup-tokenon the VPS — it will always time out due to Cloudflare - The token is stored in
~/.bashrcon the VPS asCLAUDE_CODE_OAUTH_TOKEN - Both
patrickandasiausers have the same token configured - The token is tied to Patrick’s Max subscription (pat@baseworks.com)
Current Status
Section titled “Current Status”| Item | Status |
|---|---|
| Token generated | 2026-03-11 |
| Token expires | ~2027-03-11 |
| patrick user | Configured |
| asia user | Configured |
Created 2026-03-11 by Claude Code on Patrick’s Mac