Short version: rent a server with at least 4 GB of RAM running Ubuntu 20.04 or later, create a normal user, run curl -fsSL https://claude.ai/install.sh | bash, start claude, open the login link on another device and paste the code back into the terminal. Run it inside tmux and make SSH reachable only over Tailscale.
Why put Claude Code on a VPS
Three reasons. It is always on, so a long task doesn't stop when your laptop lid closes. It is reachable from anywhere, including your phone. And it is separate from your personal machine: an agent that runs shell commands is not sitting next to your browser profiles and documents.
The cost is a monthly bill and a server to maintain. A desktop that stays on at home gets you the first two for free.
Requirements
From the official setup page, as of 2 October 2026:
- OS: Ubuntu 20.04+, Debian 10+ or Alpine Linux 3.19+.
- Hardware: 4 GB+ RAM, x64 or ARM64 processor.
- Network: an internet connection. Shell: Bash or Zsh.
- Location: an Anthropic supported country.
- Account: Pro, Max, Team, Enterprise or Console. The free claude.ai plan does not include Claude Code.
You do not need Node.js. The recommended installer downloads a native binary. The npm package still exists and needs Node.js 22 or later, but it installs the same binary.
Which VPS is best? There isn't one; go by criteria. RAM first: 4 GB is the documented minimum, and your builds and tests run on the same box, so size for those too. Either CPU architecture works. Given the location requirement, a region inside a supported country is the safe choice, and one near you keeps typing over SSH responsive. After that it is price.
1. Create a normal user
If your provider logs you in as root with an SSH key, make an ordinary user first and work as that user:
adduser dev adduser dev sudo mkdir -p /home/dev/.ssh cp ~/.ssh/authorized_keys /home/dev/.ssh/ chown -R dev:dev /home/dev/.ssh chmod 700 /home/dev/.ssh && chmod 600 /home/dev/.ssh/authorized_keys
The installer puts Claude Code in the user's own ~/.local/bin, the docs warn against sudo npm install -g, and on Linux Claude Code refuses to start with --dangerously-skip-permissions as root or under sudo. An agent running as root can also break the whole server rather than one home directory.
2. Install Claude Code
Log in as the new user and run the documented install command:
curl -fsSL https://claude.ai/install.sh | bash claude --version
Native installs update themselves in the background. If the shell says claude: command not found, the install directory isn't on your PATH yet:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
If the installer prints Killed, the server ran out of memory. The docs call this common on small VPS instances and say installing needs roughly 512 MB free. Their fix is swap, then retry:
sudo fallocate -l 2G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile
3. Sign in on a machine with no browser
The docs describe three ways:
- Login link and code (subscription). Run
claude, copy the login URL from the terminal and open it on your laptop or phone. After you sign in, the browser shows a login code instead of redirecting, which the docs describe as common over SSH; paste it at thePaste code here if promptedprompt. If pasting there does nothing,claude auth loginreads the code from standard input instead. On Linux the login is stored in~/.claude/.credentials.jsonwith mode 0600. - Long-lived token (subscription, for scripts). On a machine that has a browser,
claude setup-tokenprints a one-year OAuth token. Set it on the server asCLAUDE_CODE_OAUTH_TOKEN. It can only make model requests, so it cannot start Remote Control sessions. - API key (Console billing). Set
ANTHROPIC_API_KEY. Claude Code asks once to approve the key instead of opening a browser. An approved key is used ahead of a subscription login, so don't leave one exported by accident.
Inside Claude Code, /status shows which method is active.
4. Keep sessions alive
An SSH connection that drops takes its programs with it unless they run inside a multiplexer. With tmux (sudo apt install tmux):
tmux new -s claude # work, then detach with Ctrl-b d tmux attach -t claude
The Claude Code docs give three lines for ~/.tmux.conf so Shift+Enter and notifications work inside tmux:
set -g allow-passthrough on set -s extended-keys on set -as terminal-features 'xterm*:extkeys'
For several agents at once, see Herdr vs tmux.
5. Lock the server down
Keys only. In /etc/ssh/sshd_config set PasswordAuthentication no and PermitRootLogin no, then sudo service ssh restart. Ubuntu reads /etc/ssh/sshd_config.d/*.conf first and the first value wins, so check nothing there contradicts you: sudo grep -ri passwordauthentication /etc/ssh/. Test a fresh login in a second window before closing your current session.
No public SSH at all. Install Tailscale on the server (curl -fsSL https://tailscale.com/install.sh | sh, then sudo tailscale up), confirm you can SSH to its 100.x.y.z address, and only then turn on the firewall:
sudo ufw allow in on tailscale0 sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw enable
With no public SSH rule in ufw (delete one if it exists; Tailscale's guide shows how), port 22 is closed to the internet and open to your own devices. The risk is locking yourself out: if Tailscale stops, or its key expires, your only way in is the provider's web console, so find that first. SSH without port forwarding explains the approach and the Tailscale SSH guide covers the phone side.
A VPS is not a licence to skip permission checks. The docs reserve --dangerously-skip-permissions for isolated containers or VMs without internet access, which a server holding your Git credentials is not. Reduce the prompts properly instead.
Using it from your phone
Any SSH app plus Tailscale works: connect, run tmux attach -t claude, carry on. Anthropic's own Remote Control (claude remote-control) shows the session in the Claude app; it needs a subscription login made with /login, not an API key, and the process must keep running, so start it inside tmux. All the options are compared here.
A VPS you rent and control counts as your own machine, so Melta, coming soon for iPhone and Android, works with it too; it uses Herdr on the server rather than tmux, which its setup command installs.
Will running Claude Code on a VPS get you banned?
We found no official statement that prohibits it. The docs, their legal and compliance page, the Usage Policy and the Consumer Terms say nothing against running Claude Code on a server you control, and the docs themselves cover SSH logins and small VPS installs. What they do say:
- The Consumer Terms forbid sharing your login or credentials or making your account available to anyone else. One subscription shared by a team on one server breaks that.
- Pro and Max limits "assume ordinary, individual usage".
- The Consumer Terms restrict automated access except through an API key or where Anthropic explicitly permits it. For unattended scripts, the documented routes are an API key or
claude setup-token. - Anthropic says it may enforce these restrictions without prior notice.
We can't verify the ban reports that circulate online, so treat them as anecdotes and read the terms yourself.
Common questions
What are the Claude Code VPS requirements? Ubuntu 20.04+, Debian 10+ or Alpine 3.19+, 4 GB or more of RAM, an x64 or ARM64 CPU and an internet connection.
Can I use my Pro or Max subscription on a VPS? Yes. The legal page says nothing prevents you signing in to the unmodified Claude Code binary with your own subscription. Keep it to yourself.
Can I run Claude Code as root? Use a normal user with sudo instead. Bypass mode is refused as root, and a mistake as root reaches the whole server.
Sources
- Claude Code docs: advanced setup and system requirements
- Claude Code docs: authentication
- Claude Code docs: troubleshoot installation and login
- Claude Code docs: permission modes
- Claude Code docs: terminal configuration (tmux)
- Claude Code docs: Remote Control
- Claude Code docs: legal and compliance
- Anthropic: Consumer Terms of Service
- Anthropic: Usage Policy
- Tailscale docs: use ufw to lock down an Ubuntu server
- Ubuntu Server docs: user management
- Ubuntu manpages: sshd_config