Tutorial, Ubuntu 24.04
Claude Code on a VPS. Your coding agent keeps working when your laptop sleeps.
Guides for this disagree on almost everything: how much memory, how to log in without a browser, whether to skip permissions. Here’s what Anthropic’s own docs say, as a setup you can paste.
Claude Code on a server, per Anthropic
- MemoryStated requirement4 GB+
- Phone, Remote ControlNeeds a plan loginNo API key
- Skipped permissionsAs rootRefused
So: 4 GB or more, a normal user, and the right login.
A Lite 6 for Claude Code
$8
- 6 GB RAM
- tmux
- Remote Control
- Codex CLI
- Git
- Always on
Billed by the hour, paid in crypto, with no ID.
The short answer
Use a server with 4 GB of RAM or more (Anthropic’s stated requirement), make a normal user, install with curl -fsSL https://claude.ai/install.sh | bash, and run claude inside tmux. Log in by copying the URL to your laptop’s browser and pasting the code back.
From your phone, either attach to tmux from an SSH app, or run claude remote-control and open the session in the Claude app. Remote Control needs your Claude plan login, not an API key.
On your laptop, Claude Code stops when the lid closes. On a server it keeps going: a long refactor, a test suite, a task you started from your phone on the train.
Three things trip people up: logging in with no browser, keeping the session alive after SSH disconnects, and letting it work without approving every step safely. Each has a documented answer.
In this guide you’ll learn
- What you need: server, plan, country
- A setup builder for your login and phone
- Three ways to log in, and their limits
- Phone access: SSH, Remote Control, or the web
- Unattended work, safely
Chapter 1
What you need to run Claude Code on a VPS
Anthropic lists the requirements plainly. Most VPS guides skip at least one.
- 4 GB of RAM or moreHow to check: That’s Anthropic’s stated hardware requirement, on x64 or ARM64. A 2 GB server is below it, whatever some guides say. A Lite 6 has 6 GB.
- Ubuntu 20.04 or newerHow to check: Or Debian 10+, or Alpine 3.19+. Every Lite offers current Ubuntu.
- A Claude plan or an API keyHow to check: Pro, Max, Team, Enterprise or a Console account. The free plan doesn’t include Claude Code.
- A supported countryHow to check: Anthropic’s docs list being in a supported country as a requirement. Check their list for where you are before you start.
Chapter 2
Build your setup
First lock down SSH (key-only logins) and turn on a firewall. Then tell the builder how you’ll log in and connect.
Your setup
4 steps.
1. As root: a user for the agent, and tmux
adduser dev usermod -aG sudo dev apt update && apt install -y tmux git
2. As dev: install Claude Code
su - dev curl -fsSL https://claude.ai/install.sh | bash claude --version && claude doctor
3. Log in with your Claude plan
claude # Copy the login URL into a browser on your computer, # sign in, then paste the code back at "Paste code here if prompted".
4. Keep a session you come back to
tmux new -s claude cd ~/your-project && claude # Detach with Ctrl-b then d. From any SSH app, later: tmux attach -t claude
Chapter 3
Log in to Claude Code with no browser
The server has no browser, so the login happens on your laptop and comes back as a code. Which way you pick decides what works later.
| Method | How | Billed | Remote Control |
|---|---|---|---|
| Plan login | Run claude, open the URL on your laptop, paste the code back | Your plan | Works |
| API key | Set ANTHROPIC_API_KEY in a file only you can read | Per token | Not supported |
| One-year token | claude setup-token, then set CLAUDE_CODE_OAUTH_TOKEN | Your plan | Not supported |
On Linux the plan login is saved in ~/.claude/.credentials.json, readable only by you. It expires eventually; Claude Code warns you three days before, and a session that outlives it stops until you log in again. Run /status inside Claude Code to see which login is in use.
Chapter 4
Use Claude Code from your phone
Three honest options, each with its own trade.
| SSH app and tmux | Remote Control | Claude Code on the web | |
|---|---|---|---|
| Runs on | Your VPS | Your VPS | Anthropic’s cloud |
| On your phone | A terminal | The Claude app | The Claude app or browser |
| Needs | An SSH app and your key | A plan login, the process kept running | A plan login and GitHub |
| Inbound ports | SSH | None: outbound HTTPS only | None |
| Your own tools and services | Yes | Yes | Its environment |
Remote Control’s docs say to start it inside tmux on a remote machine, so it keeps running after you disconnect. Claude Code on the web is Anthropic’s own hosted option, with no separate charge for the machine; a VPS is for when you want your own OS, tools, databases, or code that isn’t on GitHub.
Chapter 5
Let it work unattended, safely
Approving every step defeats the point of a server. Anthropic’s answer is auto mode: Claude works through long tasks with background safety checks.
Start in auto mode
claude --permission-mode auto
Or script a task
claude -p "Run the tests and fix what fails" --permission-mode auto --output-format json
Optional: sandbox shell commands
sudo apt install -y bubblewrap socat
Then run
/sandboxin Claude Code. The sandbox is off by default and covers shell commands only.
- No production secrets on the boxHow to check: The agent can read what its user can read: deploy keys, cloud credentials, .env files. Give it a server of its own.
- Only trusted repositoriesHow to check: Without
--bare,claude -pruns a project’s hooks and MCP servers even in a folder you haven’t trusted.
Chapter 6
Other coding agents on the same server
OpenAI’s Codex CLI installs the same way and runs fine next to Claude Code.
Install
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Log in with no browser
codex login --device-auth
Enter the one-time code in a browser on your laptop.
Codex can keep its login in ~/.codex/auth.json as plain text; OpenAI says to treat that file like a password. Our advice: chmod 700 ~/.codex.
Now it’s your move
4 GB or more, a normal user, the native installer, tmux, and the login that matches how you connect. Then auto mode for long tasks.
Deploy a Lite 6 and paste the setup above. Want Claude to use your own tools? Host an MCP server on the same box.