Coding agents such as Anthropic's Claude Code and OpenAI's Codex CLI read a project, edit files and run commands from the terminal. Installing them on a VPS rather than your own computer has three advantages: the session keeps going when you close your laptop, the agent works in an environment isolated from your personal files, and you can reach it over SSH from any device. This guide installs both tools on a Linux VPS and sets up a clean, safe environment.
1. Why a VPS for a coding agent
| Criterion | On your computer | On a VPS |
|---|---|---|
| Long task (refactor, migration, tests) | Stops when you close the computer | Continues inside a tmux session |
| Access to your personal files | The agent works on your machine | Isolated: only the repositories cloned on the server |
| Access from several devices | No | Yes, over SSH from a PC, a Mac or a phone |
| Linux environment matching production | Depends on your system | Yes |
| Starting over after a mistake | Tricky | Reinstall the server in a few minutes |
2. Preparing the server
Start from a Linux VPS running Ubuntu 24.04 and secure it first: personal user, SSH key, firewall. See first steps on your VPS. Then create a user dedicated to the agent, without root rights:
adduser --disabled-password --gecos "" agent
apt update && apt install -y git tmux curl build-essential
su - agent
Working with a user that has no admin rights limits what the agent can change on the system, even if a command goes wrong.
3. Installing Claude Code
curl -fsSL https://claude.ai/install.sh | bash
claude
On first launch, Claude Code offers to sign in with your Claude account or an Anthropic API key. On a server without a browser, it shows a URL to open on your computer to confirm the sign-in. Then move into a project folder and run claude.
4. Installing Codex CLI
Codex CLI installs with npm, so you need Node.js. Install the LTS version as root, then the tool:
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt install -y nodejs
npm install -g @openai/codex
su - agent
codex
Codex signs in with your ChatGPT account or an OpenAI API key. Both agents can live side by side on the same server.
5. Keeping the session open with tmux
Without precautions, the agent stops as soon as the SSH connection drops. tmux keeps the session alive on the server:
tmux new -s agent # create a session named "agent"
claude # or codex, inside the project folder
# Ctrl+B then D to detach: the agent keeps working
tmux attach -t agent # to come back later, from any device
You can open several windows in the same session (Ctrl+B then C): one for the agent, one to watch tests or logs.
6. Secure Git access
The agent needs to clone and push code. Do not give it your personal SSH key:
- One deploy key per repository: create a dedicated key on the server (
ssh-keygen -t ed25519 -f ~/.ssh/repo) and add it as a deploy key for that repository only. - Or a narrowly scoped token: an access token restricted to one repository and the rights it needs, with an expiry date.
- A working branch: let the agent work on a branch, and review before merging.
7. Security rules to follow
- No production secrets on the agent's server: use test databases and test keys.
- Review the commands it proposes before allowing them, at least while you are getting to know the tool. Both agents ask for confirmation before running a command or editing a file, depending on the mode you choose.
- API keys in environment variables, with limited rights and a spending cap at the provider.
- Updates: rerun the Claude Code installer or
npm update -g @openai/codexregularly, and keep the system updated. - Backups: if the agent works on files not yet pushed, back them up. See backups with Borg.
8. Which configuration to choose
| Use | RAM | vCPU |
|---|---|---|
| One agent, small projects, scripts | 2 GB | 2 |
| Web projects with Node.js or Python dependencies, tests | 4 to 8 GB | 2 to 4 |
| Several agents in parallel, builds, Docker containers | 8 to 16 GB | 4 to 6 |
It is not the agent that consumes resources, but what it launches: installing dependencies, compiling, test suites, containers. NVMe storage speeds these up noticeably. Plans are on the NVMe VPS page.
9. The total cost
It has two distinct parts:
- The server: the VPS price, fixed each month.
- The model: your Claude or ChatGPT subscription, or your API key usage, billed by Anthropic or OpenAI according to consumption.
With an API key, set a monthly spending cap in the provider's console: an agent running for a long time on a large project can consume a lot.
10. A typical working day
Here is how working with an agent on a remote server is organised in practice:
- In the morning, from your computer:
ssh agent@VPS_IP, thentmux attach -t agent. You find the session exactly where you left it. - You describe a precise task: "add pagination to the orders API and write the matching tests". The more concrete the instruction, the more reliable the result.
- The agent reads the project, proposes a plan, edits files and runs the tests. You approve commands as they come, or let it work more autonomously on a dedicated branch.
- You detach with
Ctrl+BthenDduring a long task, such as a dependency migration, and come back later, even from your phone with an SSH app. - You review the branch with
git diffor in your forge's interface, then merge.
To go faster, add an instructions file at the root of each project (for example CLAUDE.md for Claude Code or AGENTS.md for Codex) describing the test commands, coding conventions and what the agent must never touch. The agent rereads it at every session.
11. Going further: autonomous agents and notifications
A VPS also lets you run agents that work without you, for example to triage tickets, watch a repository or prepare a report every morning:
- Scheduled tasks: a script started by cron that calls the agent non-interactively on a precise task, then saves the result.
- Notifications: when a task ends, a message sent to Telegram or Discord with a simple HTTP call.
- Automations: n8n can trigger the agent from a form, an email or a webhook.
In every case, keep the same caution: limited rights, test keys, human review before anything goes to production.
Frequently asked questions
Do Claude Code or Codex need a graphics card?
No. The models run at Anthropic and OpenAI; the server only runs the command-line tool and the commands it launches. A standard VPS is enough.
Does Claude Code work without a browser on a server?
Yes. On first launch, it shows a URL to open on another device to confirm the sign-in, or you can use an Anthropic API key.
How do I get back to a session after closing my computer?
Start the agent inside tmux, detach with Ctrl+B then D, and come back later with tmux attach from any device connected over SSH.
Can Claude Code and Codex run on the same VPS?
Yes, they install side by side. Plan for 4 GB of RAM or more if you use them in parallel on projects that compile or run tests.
Can the agent break my server?
It can run commands, hence the value of a user without root rights, reviewing its proposals and keeping no production secrets on the server. If something goes wrong, a VPS can be reinstalled in a few minutes.



