Skip to content

Claude Code VPS Authentication — Setup Guide

Created 2026-03-11
Updated 2026-03-11
Tags infrastructureclaude-codevpsauthentication

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.

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).

Run these steps from any Mac that has Claude Code installed and logged in:

Open Terminal and run:

Terminal window
claude setup-token

It will open a browser, you authenticate, and it gives you a token starting with sk-ant-oat01-.... Copy the full token.

SSH into the VPS and replace the token in .bashrc for both users:

Terminal window
# For patrick
ssh patrick@46.224.129.16
# Edit ~/.bashrc — find the CLAUDE_CODE_OAUTH_TOKEN line and replace the token value
# Then: source ~/.bashrc
# For asia
ssh patrick@46.224.129.16
sudo nano /home/asia/.bashrc
# Find the CLAUDE_CODE_OAUTH_TOKEN line and replace the token value
Terminal window
ssh patrick@46.224.129.16 'PATH=$HOME/.local/bin:$PATH claude --print "say hello"'
  • Do NOT attempt claude login or claude setup-token on the VPS — it will always time out due to Cloudflare
  • The token is stored in ~/.bashrc on the VPS as CLAUDE_CODE_OAUTH_TOKEN
  • Both patrick and asia users have the same token configured
  • The token is tied to Patrick’s Max subscription (pat@baseworks.com)
ItemStatus
Token generated2026-03-11
Token expires~2027-03-11
patrick userConfigured
asia userConfigured

Created 2026-03-11 by Claude Code on Patrick’s Mac