Claude Code on a VPS: sizing, setup and staying safe

Claude Code runs on a VPS with at least 4 GB of RAM, an x64 or ARM64 processor and Ubuntu 20.04+, Debian 10+ or Alpine 3.19+, used from a country Anthropic supports. Run it as a normal user with SSH keys and a firewall, sign in by pasting a code, and keep sessions in tmux.

Contents

Claude Code runs on any VPS with at least 4 GB of RAM, an x64 or ARM64 processor and Ubuntu 20.04+, Debian 10+ or Alpine 3.19+, as long as you use it from a country Anthropic supports. Run it as a normal user, log in with SSH keys behind a firewall, sign in by pasting a code from your own browser, and keep each session in tmux.

The Claude Code facts below come from Anthropic's docs and terms, and the server steps from the Ubuntu Server docs and the OpenSSH manual, all read on 24 October 2026.

What a VPS needs to run Claude Code#

Anthropic's system requirements list five things, and the last one is a place, not a part.

Requirement What Anthropic lists What it means for a VPS
System Ubuntu 20.04+, Debian 10+, Alpine Linux 3.19+ (also macOS 13+, Windows 10 1809+, Windows Server 2019+) Any current Ubuntu or Debian image works
Hardware 4 GB+ RAM, x64 or ARM64 processor ARM plans are fine; 2 GB plans are below the line
Network An internet connection Outbound HTTPS; nothing has to be open inbound except SSH
Shell Bash, Zsh, PowerShell or CMD Bash is already there
Location Anthropic's supported countries Where you are, see below

You also need a Pro, Max, Team, Enterprise or Console account, because the setup page says the free claude.ai plan doesn't include Claude Code. The VPS bill and the Claude bill are separate.

How big should a Claude Code VPS be?#

Two numbers from Anthropic's own pages show why 4 GB is a floor and not a size. The installer needs roughly 512 MB free, and the install troubleshooting page says a Killed message during install "is common on small VPS and cloud instances". A running session shows a critical memory warning once its heap passes 2.5 GB, per the troubleshooting page. And everything the agent starts (a dependency install, a build, a test run, a dev server) uses memory on top of that.

So size for the work, not for the CLI: the 4 GB floor is for Claude Code itself. Two agents side by side, each running its own builds, want more, and each extra checkout or worktree needs disk space for its own dependencies. Whatever you pick, add a swap file, which is Anthropic's own fix for a killed install:

bash
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Add /swapfile none swap sw 0 0 to /etc/fstab so it survives a reboot.

Check the processor too. If claude prints Illegal instruction on a VPS with the right architecture, the hypervisor may not be passing AVX through to the guest. Anthropic gives the test, grep -m1 -ow avx /proc/cpuinfo, and says an empty result means no AVX and no native-binary workaround.

Does it matter which country the VPS is in?#

Anthropic's supported-countries page, in the version that takes effect on 12 November 2026, says its products, Claude Code named among them, "are available only in the countries and regions listed below. Any country or region not listed is unsupported." It then spells out what that covers: "Use by persons while physically located in an unsupported region", and use by companies incorporated or headquartered in one, or majority-owned or controlled from one, "regardless of whether such individuals are physically located in a supported region."

That rule is about people and companies. The page we read says nothing about where a server sits, and a box in Frankfurt doesn't change where you are. The data centre still matters for a practical reason: the install troubleshooting page says that if an install fails quoting "App unavailable in region", Claude Code isn't available in your country. Pick a data centre in a listed country, close to you, because every keystroke in an SSH terminal makes the round trip.

Can you get banned for running Claude Code on a VPS?#

We found nothing in Anthropic's Consumer Terms (effective 8 October 2025) or the supported-countries page that rules out a rented server, and Anthropic's install docs have a section written for small VPS instances. What the terms do contain applies on a server as much as on a laptop. You must use the service in line with the Supported Regions Policy. And "You may not share your Account login information, Anthropic API key, or Account credentials with anyone else", which matters on a box several people can log in to. The same terms rule out reaching the services "through automated or non-human means, whether through a bot, script, or otherwise", except through an Anthropic API key "or where we otherwise explicitly permit it". For CI pipelines and scripts, the Claude Code docs offer claude setup-token (more below), not a copied login.

Claude Code VPS setup, step by step#

These steps are for a fresh Ubuntu or Debian VPS where you start as root. The SSH side, from making a key to keeping connections alive and forwarding a dev server's port, is in running Claude Code over SSH; this list is what to do on the server around it.

  1. Make a normal user. adduser dev, then usermod -aG sudo dev. Copy your public key into /home/dev/.ssh/authorized_keys (owned by dev, mode 600) and log in as dev from a second terminal before you change anything else.
  2. Turn off password and root logins. Create /etc/ssh/sshd_config.d/10-hardening.conf with PasswordAuthentication no, KbdInteractiveAuthentication no and PermitRootLogin no. OpenSSH's manual gives PasswordAuthentication a default of yes, and uses "the first obtained value" for each keyword; Ubuntu's main config includes that folder at the very top, so a file there wins over the main file, and a low number such as 10- puts it ahead of other files in the folder. Check with sudo sshd -t, restart with sudo systemctl restart ssh.service, and keep your current session open until a new login works.
  3. Turn the firewall on. Ubuntu's firewall tool, ufw, is disabled by default. Allow SSH first, then enable: sudo ufw allow 22, sudo ufw enable, sudo ufw status. Leave dev server ports closed and reach them through an SSH tunnel instead.
  4. Keep the system patched. On Ubuntu Server, unattended-upgrades is installed and on by default for security updates. It doesn't reboot on its own, so reboot when a kernel update asks for it.
  5. Install Claude Code as dev, not root. curl -fsSL https://claude.ai/install.sh | bash, then claude --version and claude doctor. The native install updates itself in the background, and a new version takes effect the next time Claude Code starts. Anthropic's signed apt, dnf and apk repositories are the alternative if you'd rather update with the system; those don't update by themselves. The commands for each distribution, Alpine's extra packages included, are in installing Claude Code on Linux.
  6. Sign in without a browser. Run claude auth login, open the link it prints on your own computer, approve, and paste the code the browser shows into the SSH session. The authentication page says this happens because the browser "can't reach Claude Code's local callback server", which is common over SSH.
  7. Start every session inside tmux. tmux new -s app, run claude, detach with Ctrl-b d. The session keeps going when your connection drops. One tmux session per project keeps several agents apart. Picking the machine and keeping it awake, for a home server as much as a VPS, is in running Claude Code on an always-on machine.

Keep secrets off the box#

On Linux, Claude Code saves your login to ~/.claude/.credentials.json with file mode 0600. That stops other ordinary users, not root and not anything running as dev. Treat the VPS as a place your Claude login lives, and give it as little else as you can.

Give the server its own GitHub access rather than forwarding your laptop's SSH agent: a deploy key for one repository, or a fine-grained token limited to the repos it works on. Keep .env files and production keys out of the repository and out of the agent's reach; keeping secrets from coding agents has the deny rules and the sandbox setup. For an unattended script, claude setup-token prints a one-year token you set as CLAUDE_CODE_OAUTH_TOKEN. It only makes model requests, so it can't start Remote Control, and it isn't saved anywhere unless you save it.

On a VPS it is tempting to run --dangerously-skip-permissions, on the theory that a rented box has nothing to lose. That holds only if it really holds nothing: no long-lived keys, no production access, a repo you trust. Using skip-permissions safely has the full list.

How Shuriken does it#

In Shuriken, a VPS is a server, and adding one replaces steps 5 to 7 above.

  1. In the app, open Settings › Devices › Add device and choose A server.
  2. Pick Linux. The app gives you one install command made for your account, valid for an hour.
  3. Run it on the VPS over SSH, once. It uses sudo, for the system service.

The installer signs the server in to your account, then sets up Git, the GitHub CLI, ripgrep, Claude Code, Codex and the other agent CLIs for the providers you have sources for, and asks for your GitHub sign-in (Enter skips it). It reports success only when Git, the GitHub CLI, Claude Code and Codex all run.

The worker never runs as root: a root install on Linux runs it as its own shuriken system user. It runs as a service (systemd or OpenRC) that starts with the machine and restarts if it fails. It updates itself only to releases signed with our release key, and waits until no agent is mid-turn before it restarts into one. You don't sign in to Claude on the server: your sources (the accounts and keys you add to Shuriken) reach it end-to-end encrypted from the app. Your chats run there, and you follow them from your computer or any browser.

On the Free plan a server is one of your two linked devices; Pro has no device limit. We also plan to rent out servers we set up for you, with no date or price yet; until then, bring your own VPS. The server page has the short version, and you can download Shuriken to add yours.

Sources

  1. Advanced setup: system requirements and installation (Claude Code docs) (accessed 24 October 2026)
  2. Troubleshoot installation and login: low-memory servers, Illegal instruction, App unavailable in region (Claude Code docs) (accessed 24 October 2026)
  3. Troubleshooting: high CPU or memory usage (Claude Code docs) (accessed 24 October 2026)
  4. Authentication: credential storage and long-lived tokens (Claude Code docs) (accessed 24 October 2026)
  5. Supported countries and regions (Anthropic) (accessed 24 October 2026)
  6. Consumer Terms of Service (Anthropic) (accessed 24 October 2026)
  7. sshd_config(5), OpenBSD manual (accessed 24 October 2026)
  8. OpenSSH server (Ubuntu Server docs) (accessed 24 October 2026)
  9. Firewalls (Ubuntu Server docs) (accessed 24 October 2026)
  10. Automatic updates (Ubuntu Server docs) (accessed 24 October 2026)

Frequently asked questions

How much RAM does Claude Code need on a VPS?

Anthropic lists 4 GB or more. Installing needs roughly 512 MB free, and a single session shows a memory warning once its heap passes 2.5 GB, so leave room above 4 GB for builds and for every extra session. Add swap either way.

Does Claude Code work on a VPS?

Yes. It runs on any VPS that meets Anthropic's requirements: 4 GB of RAM or more, an x64 or ARM64 processor, and Ubuntu 20.04+, Debian 10+ or Alpine 3.19+; on x64 the hypervisor must also pass AVX through. You sign in by opening a link on your own computer and pasting the code back.

Can I get banned for running Claude Code on a VPS?

We found nothing in Anthropic's Consumer Terms or its supported-countries page against a rented server. The terms do require use from a supported country, forbid sharing your login, and rule out access by bot or script unless it goes through an API key or Anthropic explicitly permits it.

Does the VPS have to be in a supported country?

Anthropic's policy names where you are and where your company is based or controlled from; it says nothing about where a server sits. An install from a region Anthropic doesn't serve can fail with App unavailable in region, so pick a data centre in a listed country too.

Which user should Claude Code run as on a server?

A normal user with sudo, not root. Its login is saved in that user's ~/.claude/.credentials.json with file mode 0600, so anyone who can act as that user or as root can read it. Don't share that account.

Free tools