Running Claude Code (Anthropic's terminal-based agent) locally is transformative—until you close your laptop lid, put your machine to sleep, and kill an active refactoring session.
Worse, bouncing between your office Mac and home desktop inevitably causes environment drift (broken venvs, missing dependencies, unsaved git state).
The standard workaround—buying a dedicated Mac mini or renting expensive cloud Mac instances ($60–$100/mo)—is overkill.
Here is the truth: Claude Code requires ZERO GPU compute. All LLM inference happens on Anthropic's cloud. Your host machine only runs a lightweight CLI client, Git operations, and your local build tools.
A cheap $5/mo Linux VPS running Ubuntu 24.04 LTS + tmux gives you a 24/7 persistent, immune-to-disconnect AI development workbench.
Originally published with in-depth hardware benchmarks and provider comparisons at VPSRankings.
4 Remote Architecture Patterns Compared
| Workflow | Code Location | Key Advantage | Tradeoff / Limitation | Rating |
|---|---|---|---|---|
| CLI + tmux | VPS | Minimal footprint (~150MB), 100% resilient to dropped SSH | Pure terminal workflow | ★★★★★ |
| VS Code Remote-SSH | VPS | Full native IDE (Diff viewer, Git gutter, file tree) | Requires stable local client | ★★★★★ |
| Official Remote Control | VPS | Web & Mobile native handoff via claude.ai/code | Requires claude.ai subscription login | ★★★★☆ |
| CC Desk Tunnel (Open Source) | Local Machine | Keeps code on local Windows/Mac; VPS acts as proxy | Reverse tunnel introduces broad remote execution risks | ★★★☆☆ |
Hardware Sizing & Pre-Flight Checks
Don't starve your machine. While the Claude CLI is featherlight, npm install, TypeScript checks, and test suites will spike memory.
- Lightweight Scripting: 1–2 vCPU / 2GB RAM (Mandatory: Add 2GB Swap to prevent OOM kills during builds).
- Full-Stack Sweet Spot (Recommended): 2 vCPU / 4GB RAM / 40–50GB NVMe SSD (e.g., Hetzner CX23 or RackNerd promo).
- Multi-Container / Docker Workloads: 4 vCPU / 8GB RAM.
Step-by-Step Installation (Ubuntu 24.04)
Never run AI coding agents as root. Always isolate permissions within a dedicated non-root user.
1. System Setup & Dedicated User
# SSH into your VPS as root ssh root@YOUR_VPS_IP # Update packages and install essentials apt update && apt upgrade -y apt install -y curl git tmux ca-certificates # Create a non-root developer user adduser developer usermod -aG sudo developer # Copy authorized SSH keys from root install -d -m 700 -o developer -g developer /home/developer/.ssh cp /root/.ssh/authorized_keys /home/developer/.ssh/ chown developer:developer /home/developer/.ssh/authorized_keys chmod 600 /home/developer/.ssh/authorized_keys Open a new local terminal and verify you can login without root:
ssh developer@YOUR_VPS_IP
2. Install Claude Code CLI
Switch to the developer user and use Anthropic's official native installation script (which handles automatic background updates):
su - developer curl -fsSL https://claude.ai/install.sh | bash source ~/.bashrc claude --version (If claude: command not found appears, append export PATH="$HOME/.local/bin:$PATH" to your ~/.bashrc).
3. Initialize Workspace & Headless OAuth
mkdir -p ~/projects/demo && cd ~/projects/demo git init claude Because your VPS has no graphical browser:
- The CLI will output a dedicated browser authorization URL.
- Open that URL on your local computer's browser, sign in to Anthropic, and approve.
- Paste the generated authorization code back into your VPS terminal.
Bulletproof Session Persistence with tmux
To ensure Claude keeps working even if your local Wi-Fi drops or your laptop sleeps:
# 1. Start a persistent session tmux new -s claude-session cd ~/projects/demo claude # 2. Detach safely (leave running in background) # Press Ctrl + B, release, then press D # 3. Later, re-attach from any device tmux attach -t claude-session Pro Tip: VS Code Remote-SSH Setup
Add the following to your local ~/.ssh/config (or Windows C:\Users\username\.ssh\config):
Host claude-vps HostName YOUR_VPS_IP User developer IdentityFile ~/.ssh/id_ed25519 ServerAliveInterval 30 Notice:
ServerAliveInterval 30is critical—it pings the server every 30 seconds to prevent NAT timeouts on hotel or home Wi-Fi.
Common Gotchas
- Do NOT run interactive Claude as a systemd service: Interactive mode demands TTY input and human confirmations. Placing it in a blind systemd loop will spam Anthropic's API and burn through tokens.
- OOM Crashes on 2GB Boxes: If running a low-memory VPS, run:
sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile sudo mkswap /swapfile && sudo swapon /swapfile echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab For detailed network latency tests, provider pricing comparisons, and mobile handoff walkthroughs, read the complete benchmark report:
👉 Full Guide & Benchmarks at VPSRankings
