Run Claude Code on a VPS or Raspberry Pi: an always-on dev machine
Choose between a VPS and a Raspberry Pi, install Claude Code, sign in without a browser, lock the machine down with Tailscale, and keep the agent running while your laptop is closed.
An AI coding agent only works while the machine it runs on is awake. If that machine is your laptop, every closed lid stops the work. The fix is a computer that never sleeps: a cheap VPS in a data centre or a Raspberry Pi on a shelf at home. Here is how to set one up for Claude Code (or Codex), sign in without a browser, keep it safe, and reach it from your phone.
1. Why run Claude Code on an always-on machine
- Long tasks finish while your laptop is closed in a bag.
- Any device can connect — phone, tablet, a borrowed computer — and find the same sessions.
- A natural sandbox: a machine with only your project on it is a far better place to let an agent work with fewer approvals than the laptop with your passwords, SSH keys and photos.
The trade-off: the agent no longer sees your local setup. Databases, MCP servers and tools you rely on have to be installed on the new machine too.
2. VPS or Raspberry Pi: which one
| VPS | Raspberry Pi | |
|---|---|---|
| Cost | monthly fee | one-off purchase, then electricity |
| Reachable from anywhere | public IP | through Tailscale or similar |
| Speed of builds and tests | pick the size you need | fine for scripts and web apps, slow for big compiles |
| Your code leaves home | yes, to the provider | no |
| Maintenance | provider handles hardware | you handle the SD card or SSD |
The agent itself is light — it mostly waits for the model. What needs CPU and RAM is
everything it runs: npm install, compilers, test suites. As a rule of
thumb, 2 vCPUs and 4 GB of RAM are a comfortable minimum for a VPS. For a
Pi, take a Raspberry Pi 5 with 8 GB, the 64-bit Raspberry Pi OS (Claude
Code needs arm64), and boot from an SSD rather than an SD card — node_modules
wears SD cards out quickly.
3. Prepare the machine
On a fresh Ubuntu or Debian VPS, as root, create a normal user first:
adduser dev
usermod -aG sudo dev
# copy your SSH key, then log in as dev from now on
rsync --archive --chown=dev:dev ~/.ssh /home/dev
Then, as that user, the basics:
sudo apt update && sudo apt upgrade -y
sudo apt install -y git tmux build-essential curl
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Add a deploy key or a fine-grained GitHub token for just the repositories this machine needs, not your personal SSH key that can push everywhere.
4. Install Claude Code and sign in without a browser
curl -fsSL https://claude.ai/install.sh | bash
claude --version
Signing in on a machine with no browser works fine. Run claude and choose to
log in with your Claude account. When no browser opens, press c to copy the
login URL, open it on your phone or laptop, sign in, and paste the code the page shows
back into the terminal.
Two alternatives for a machine nobody sits at:
- API key: set
ANTHROPIC_API_KEYin the environment and you pay per token instead of using a subscription. It takes precedence over a subscription login once you approve it. - Long-lived subscription token:
claude setup-tokenruns the same browser sign-in and prints a token valid for a year. Put it inCLAUDE_CODE_OAUTH_TOKENon the server. It can only make model requests, so Remote Control does not work with it.
Codex works the same way: install it with npm install -g @openai/codex and
sign in with an API key or the device-code login described in
codex login --help. (If you control the agent through coden, the app does
all of this for you — see the last section.)
5. Lock it down: SSH, firewall, Tailscale
A VPS on the public internet gets probed within minutes. The minimum:
# /etc/ssh/sshd_config
PasswordAuthentication no
PermitRootLogin no
sudo systemctl restart ssh
sudo ufw allow OpenSSH
sudo ufw enable
Better still, install Tailscale and close public SSH entirely — the machine is then reachable only from your own devices. On a Raspberry Pi at home this is the only setup that makes sense: no ports opened on the router at all.
Keep secrets for production off this machine. If the agent needs credentials to run the app, give it a development database and test keys.
6. Keep the agent running
The simplest way is tmux: start the agent inside a session and it keeps going when you disconnect.
tmux new -A -s agent
cd ~/projects/app
claude
From the phone, connect with Mosh and reattach — the session survives network changes and a locked screen. A reboot ends tmux sessions, so start the work again after kernel updates.
7. Control it from your phone
A terminal over Mosh works, but you have to keep checking whether the agent is waiting for you. With coden, the always-on machine runs the coden Server and the phone app talks to it. The Server is a Debian and Ubuntu package for both amd64 and arm64, so it runs on a VPS and on a Raspberry Pi alike. Add the repository from the download page, then:
sudo apt install coden-server
tmux new -A -s coden
coden-server start --dir ~/projects/app
One Server serves one project directory. The package does not install a system service,
which is why it runs in tmux here — it keeps going after you log out. On the first
start, with no phone paired yet, the Server prints a pairing QR code
straight into the terminal, together with the same code as text. The code is valid for
ten minutes and works once; coden-server pair makes a new one. If you are
connected over SSH from the very phone you want to pair, copy the text code and paste it
into the app instead of scanning.
What you get on the phone compared with a terminal:
- Agent sign-in from the phone. If Claude Code is missing, the Server installs it with Anthropic's official installer; you sign in to your Claude subscription in a browser on the phone and paste the code into the app. An API key works too, and so do Codex (ChatGPT account or OpenAI key) and Antigravity CLI.
- Notifications when the Agent finishes and when it waits for permission — with Allow and Deny right in the notification, without opening the app.
- A connection without a VPN: end-to-end encrypted, direct where the network allows it, otherwise through our Relay, which only passes encrypted packets along. No ports have to be opened.
- More than a chat: a terminal on the server, Tasks, git history, test results, scheduled prompts and a Preview of the app the Agent is building.
And if you would rather not run a machine at all, coden can start the Server in a GitHub Codespace right from the phone. The Codespace stops itself after four minutes without a connected phone and an idle Agent, and the app wakes it up again when you connect.
Do you see it differently? Write to support@coden-app.com.