Skip to content
Black FridayCode BLACK150: 150% on your first deposit of $100 or more, up to $500 bonus. New accounts, until 1 Dec, 00:00 UTC.Get the code
LiteKeep
Sign inDeploy a server

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.

  • 11 min read
  • 6 chapters
  • Updated

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.

  1. 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.
  2. Ubuntu 20.04 or newerHow to check: Or Debian 10+, or Alpine 3.19+. Every Lite offers current Ubuntu.
  3. 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.
  4. 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.

How you’ll use it

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

Deploy a Lite 6

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.

Claude Code login methods on a server, from Anthropic's docs
MethodHowBilledRemote Control
Plan loginRun claude, open the URL on your laptop, paste the code backYour planWorks
API keySet ANTHROPIC_API_KEY in a file only you can readPer tokenNot supported
One-year tokenclaude setup-token, then set CLAUDE_CODE_OAUTH_TOKENYour planNot 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.

Phone access to Claude Code
SSH app and tmuxRemote ControlClaude Code on the web
Runs onYour VPSYour VPSAnthropic’s cloud
On your phoneA terminalThe Claude appThe Claude app or browser
NeedsAn SSH app and your keyA plan login, the process kept runningA plan login and GitHub
Inbound portsSSHNone: outbound HTTPS onlyNone
Your own tools and servicesYesYesIts 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.

  1. Start in auto mode

    claude --permission-mode auto
  2. Or script a task

    claude -p "Run the tests and fix what fails" --permission-mode auto --output-format json
  3. Optional: sandbox shell commands

    sudo apt install -y bubblewrap socat

    Then run /sandbox in Claude Code. The sandbox is off by default and covers shell commands only.

  1. 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.
  2. Only trusted repositoriesHow to check: Without --bare, claude -p runs 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.

  1. Install

    curl -fsSL https://chatgpt.com/codex/install.sh | sh
  2. 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.