Run Claude Code on a Remote Server: VPS, SSH and tmux (2026)
How to run Claude Code on a VPS over SSH: install, headless login, tmux, Remote Control from your phone, server sizing and the security rules that matter.
Working through a similar problem? Tell us what you want to build.
Legacies is an independent digital product brand based in Bucharest, Romania, founded by Horia Stan and Alexandru Tălnaci, that builds websites, web apps and its own developer tools, including DockLab. Running an AI coding agent on a server instead of a laptop is now a normal way to work, so here is how to set it up properly.
Yes, you can run Claude Code on a remote server. Install the CLI on a Linux VPS, log in once from your browser, and start it inside tmux so it keeps working after you close your laptop. If you want to check on it from your phone, add Remote Control on top.
Quick answer
- Server: a Linux VPS with at least 4 GB of RAM, which is the minimum in Anthropic's system requirements.
- Install: one command over SSH, then run
claudeand paste the login code from your browser. - Keep it alive: run Claude Code inside a named tmux session, detach, and reattach later from any device.
- Stay safe: use a non-root user, SSH keys only, and never give the agent production secrets it does not need.
Why run Claude Code on a server at all
On a laptop, the agent stops when the lid closes. Long tasks like a refactor, a test suite fix or a dependency upgrade can take an hour. On a server, the session keeps going while you do something else.
There are other good reasons. The code sits next to the database, Docker containers and logs it works with. Builds run on server hardware, not your battery. And you can start a task at your desk and check it from your phone.
There are trade-offs too. A server is another machine to secure and pay for. An agent with shell access on a box that can reach production is a real risk. We cover both below.
The options compared
There is more than one way to "run Claude Code remotely". They solve different problems.
| Approach | Where the code runs | Survives a closed laptop | Phone access | Best for |
|---|---|---|---|---|
| SSH + tmux + CLI | Your VPS | Yes | Via an SSH app | Most solo developers |
| Remote Control | Your machine or VPS | Only if the process keeps running | Yes, via claude.ai/code or the Claude app | Checking on and steering long tasks |
| VS Code Remote-SSH | Your VPS | Not reliably | No | Editing with a full IDE |
| Claude Code on the web | Anthropic's cloud | Yes | Yes | Repos on GitHub, no server to manage |
| One workspace app for SSH and agents | Your VPS | Yes, with tmux | Depends on the app | Several servers and agents at once |
The rest of this guide focuses on the first two, because together they cover most needs.
Step by step: Claude Code on a VPS
- Pick and size the serverUse a recent Ubuntu or Debian release. Anthropic lists Ubuntu 20.04+, Debian 10+ and Alpine 3.19+ as supported, with 4 GB of RAM or more. Size the server for your build and test tools too, not only the agent.
- Create a non-root userLog in as root once, create a regular user, add your SSH public key, and turn off password logins. The agent should never run as root.
- Install Claude CodeRun the native installer as your new user. It updates itself in the background.
- Log in without a browser on the serverRun claude. Press c to copy the login URL, open it on your laptop, sign in, and paste the code back into the terminal.
- Start it inside tmuxOpen a named tmux session, start Claude Code inside it, then detach. The session keeps running after you disconnect.
Here are the commands for steps 3 to 5. First, install (from the official setup docs):
curl -fsSL https://claude.ai/install.sh | bash
claude --version
Then start a named tmux session and run the agent in your project:
tmux new -s claude
cd ~/projects/my-app
claude
To detach, press Ctrl+B, then D. To reconnect later from any machine:
tmux attach -t claude
If you prefer packages, Anthropic also publishes signed apt, dnf and apk repositories. Note that package installs do not update themselves, so you upgrade them with the rest of the system.
Logging in on a headless server
You have three options, all from the authentication docs:
| Method | How it works | Watch out for |
|---|---|---|
| Browser login | Copy the URL, sign in on your laptop, paste the code back | Renew it with /login when Claude Code warns it is about to expire |
claude setup-token | Creates a one-year OAuth token you set as CLAUDE_CODE_OAUTH_TOKEN | It cannot start Remote Control sessions |
| API key | Set ANTHROPIC_API_KEY from the Claude Console | You pay per token, not from your subscription |
Claude Code needs a Pro, Max, Ultra, Team, Enterprise or Console account. The free claude.ai plan does not include it. If you keep hitting caps on long server sessions, our guide to Claude usage limits explains how they work. Our post on how to reduce Claude Code token usage covers the habits that help most.
Checking in from your phone with Remote Control
tmux keeps the session alive. Remote Control lets you see and steer it from somewhere else. According to Anthropic's Remote Control docs, it connects claude.ai/code or the Claude mobile app to a session running on your machine. The code and files never leave that machine.
On a VPS, you combine the two. Inside your tmux session, run:
claude remote-control
Or type /remote-control inside a session that is already running. Then open the session in the Claude app or in your browser.
A few facts worth knowing at the time of writing:
- It works on Pro, Max, Ultra, Team and Enterprise plans. API keys and the
setup-tokentoken are not supported, so the server needs a normal claude.ai login. - On Team and Enterprise, an Owner has to turn it on in the admin settings first.
- The session only makes outbound HTTPS requests and never opens inbound ports, so you do not need to touch your firewall.
- Each interactive process supports one remote session. Server mode handles several at once.
- If the network drops for roughly 10 minutes, server mode exits. On a VPS, tmux plus a quick check after outages handles this.
If you just want a terminal on your phone, any SSH app works. Connect and run tmux attach -t claude. Our roundup of the best SSH clients in 2026 compares the options for Mac, Windows and mobile.
What about VS Code Remote-SSH?
It works for editing, but be careful with long agent runs. Some VPS guides and several GitHub issues report that the Claude Code extension behaves differently over Remote-SSH depending on the version. The reports say the panel can stop when your laptop disconnects. The reliable pattern is to run the Claude Code CLI inside tmux in the remote terminal and use the editor only for reviewing changes.
How much does it cost?
You pay for two things: the server and the model.
| Cost | Example at the time of writing | Notes |
|---|---|---|
| VPS, 4 GB RAM | DigitalOcean Basic, 2 vCPU: $24 a month (pricing) | 8 GB is $48 a month |
| VPS, budget EU | Hetzner shared cloud plans from EUR 5.99 a month excl. VAT (pricing) | Check that the plan you pick has 4 GB of RAM or more |
| Model access | Your Claude subscription, or pay-per-token with an API key | Long unattended runs use your limits faster |
For a solo developer, the server is usually the smaller cost. Unattended agent sessions are where the token bill grows, so give the agent narrow, well-defined tasks.
Security: the part people skip
An AI agent on a server is a process with a shell. Treat it like a new junior team member with SSH access, not like a text editor.
- Separate the agent from production. Run it on a dev or staging box. If it must touch production, give it read-only access to what it needs.
- Keep secrets out of reach. Do not leave production database passwords, cloud keys or payment credentials in files the agent can read.
- Keep the permission prompts on. Bypassing approvals on a server that can reach real data is how small mistakes turn into incidents.
- Use keys, a firewall and updates. SSH keys only, no root login, unattended security updates on.
- Review before you merge. The agent works on a branch. You read the diff.
We wrote a longer piece on vibe coding security risks with real incidents and a checklist. If you are deciding which agent to run on the box in the first place, our Claude Code vs Codex comparison covers cost and limits for both.
When one terminal is not enough
The tmux setup is great for one server and one agent. It gets messy with three servers, a staging database, a few Docker containers and two agents. You end up switching between terminal tabs, an SFTP client, a browser for logs and a text editor.
That is the problem we are building DockLab for. It puts SSH and local terminals, SFTP, a remote file editor and a built-in browser in one window. It also has an Agent Manager that works with Claude Code and Codex on local or remote hosts. AI permissions are configurable, and you use your own provider key or your local Claude Code login. DockLab is launching in beta. You can see what is in it on our products page.
Do it yourself or hand it off
Setting up Claude Code on a VPS is a good weekend project. If you are comfortable with SSH and Linux users, follow the steps above and you will have a working setup in under an hour.
Hand it to someone when the stakes change. Maybe the app your agent built now has real users and needs a proper production setup. Maybe you need to connect payments, auth or a database safely, or the server holds customer data. Our launch checklist for vibe-coded apps shows what usually needs fixing before that point. We build and fix web apps and automations with a fixed price agreed before we start. See our services and past projects, or write to [email protected] with what you are building.
Frequently Asked Questions
Can I run Claude Code on a VPS?
Yes. Claude Code runs on Linux servers, including Ubuntu 20.04+, Debian 10+ and Alpine 3.19+, with at least 4 GB of RAM according to Anthropic's system requirements. You install it over SSH with the native installer, log in once by copying the login URL to your laptop's browser, and run it inside tmux so it keeps working after you disconnect.
How do I log in to Claude Code on a server without a browser?
Run claude, press c to copy the login URL, open it on another device, sign in, and paste the code back into the server terminal. For scripts and CI you can instead generate a one-year token with claude setup-token and set it as CLAUDE_CODE_OAUTH_TOKEN, or use an API key from the Claude Console, which is billed per token.
How do I keep Claude Code running after I close SSH?
Start it inside a terminal multiplexer like tmux. Run tmux new -s claude, start Claude Code, then press Ctrl+B and D to detach. The session keeps running on the server, and you can reconnect later from any machine with tmux attach -t claude.
Can I control Claude Code from my phone?
Yes, with Remote Control. Run claude remote-control on the server, or type /remote-control in a running session, then open it in the Claude mobile app or at claude.ai/code. It works on Pro, Max, Ultra, Team and Enterprise plans, does not support API keys, and the session itself stays on your server.
How much RAM does Claude Code need on a server?
Anthropic lists 4 GB of RAM or more as the minimum. In practice, size the server for the tools the agent runs, such as builds, tests and Docker containers, because those usually need more memory than the agent itself.
Is it safe to run an AI coding agent on a production server?
It is risky. The agent can run shell commands, so a wrong command or a prompt injection could affect real data. Run it on a separate dev or staging server, keep production secrets out of reach, leave permission prompts on, and review every change before it ships.