Essential cookies keep the site working and remember this choice. They are always on. Read the cookie policy for every cookie we use.

Optional cookies

Coding7 min read

How to run coding agents in the cloud with Herdr

Run Claude Code and Codex on your own VPS with Herdr, so agent sessions keep working after you close your laptop. Server setup, SSH, firewall, logins and the daily workflow.

Herdr keeps my coding agents running when I close a terminal window. It does not keep them running when I close my laptop, shut it down, or get on a plane. Moving Herdr to a small VPS fixes that. The agents work on the server, and I connect to them from whichever device I have with me.

Herdr is my daily driver for coding projects, and I explained why in why I switched to Herdr for AI coding. This post is the next step. It covers how to run Claude Code and Codex on your own server, secure it, and use it every day.

Why move your coding agents to a server

My take is that this setup will become more common. We are going to hand more and more work to agents, and it makes little sense for that work to depend on one physical device staying awake. I would rather have one central place where the work lives, and tap into it from my laptop, my desktop or my phone.

Herdr is a terminal multiplexer built for coding agents. It runs its own background server, so an agent session survives when you close the terminal. On a laptop, that protects you from closing the wrong window. On a VPS, it means the session also survives your SSH connection dropping. You close the laptop and the agents keep working.

It helps to be clear about what runs where:

WhereWhat runs there
Your laptopSSH, your browser for logins, and optionally Cursor or VS Code
The VPSHerdr, Claude Code, Codex, the GitHub CLI and your repositories
Anthropic and OpenAIThe models themselves

Because the models run elsewhere, a small server is enough.

Choose a VPS with enough memory

I recommend at least 8 GB of RAM. My server has 2 vCPUs, 8 GB of RAM and a 100 GB disk, which gets you far for running coding agents. You can go bigger if your projects need heavy builds or tests.

Compare prices before you commit. Over the past year, many providers raised VPS prices by 2x, sometimes 3x, because of the RAM shortage. In the video I use Hostinger, which offers an Ubuntu image with Herdr already installed, so you skip that step. Any Ubuntu VPS works if you install Herdr yourself. Pick a server location close to you. You can reuse the same VPS for side projects and deployments later.

Lock down access before you install anything

Set a strong root password and add an SSH key during setup. The password protects root access on the server. The SSH key is how you connect. Generate the key on your own laptop with ssh-keygen, copy the public key into your provider's panel, and keep the private key on your laptop only.

Then save a shortcut, so you don't have to remember the IP address. Add an entry like this to ~/.ssh/config on your laptop:

Host agent-cloud
  HostName YOUR_SERVER_IP
  User developer

Now ssh agent-cloud takes you straight into the server.

The User developer line matters. Root can change every setting on the server, so I don't want my daily work or my agents running as root. Create a separate developer user, give it your SSH key and access to Herdr, and use it for everything except system changes. When you are unsure which account you are on, run whoami. Log in as root only when you need to change something at the system level.

If any of these steps are new to you, ask a coding agent to explain each command before you run it. You are about to put credentials on this machine, so you should understand how it is set up.

Restrict SSH to your own IP address

With an SSH key, only your laptop can log in. A firewall adds a second layer, so the server only accepts SSH connections from IP addresses you whitelist. The rule allows port 22 from your IP and drops all other incoming traffic.

This works best with a fixed IP address. Most home internet connections rotate your IP, which would lock you out. At Datalumina we use a VPN with a dedicated IP address for this, so the server only accepts SSH from that one address. If you don't have a fixed IP, skip the firewall and rely on the SSH key alone. Some providers, Hostinger included, let you reuse one firewall configuration across several servers, so you only set it up once.

Log in to your agents on a headless server

Your agents need three logins on the server, GitHub so they can clone, commit and open pull requests, plus Claude Code and Codex. Install the GitHub CLI as root, then switch to the developer user and install Claude Code and Codex there.

The server has no browser, so every login uses a device code. Each tool prints a URL and a code. You open the URL in the browser on your laptop and paste the code. A few quirks are worth knowing:

  • GitHub. Run the GitHub CLI login, open github.com/login/device on your laptop, and enter the code. Set your git name and email afterwards.
  • Claude Code. After you authorize in the browser, you paste a code back into the terminal. The paste looks like nothing happened because the input is hidden. Press Enter anyway.
  • Codex. The first time I used device login for my ChatGPT account, I had to enable device authentication in my security settings. Codex tells you when that is needed.

Then test both. Start Herdr, open a Codex session in one pane and a Claude Code session in another, and send each a short message.

Stuck building prototypes?

Get our production stack

What you're missing is the architecture, evaluation, and judgment to ship a real project.

See Curriculum

Set up Herdr workspaces for your repositories

A new server has an empty file system. I create one repositories folder and clone every project into it. Each repository becomes its own workspace in the Herdr sidebar.

Next, connect Herdr to your agents with herdr integrations install claude and the same command for Codex. If you want a multi-agent setup, also install the Herdr skill. It lets Codex start Claude Code sub-agents and the other way around, the same delegation I showed in my Herdr setup video.

Herdr is configured through a file. If you already tuned Herdr on your laptop, copy that configuration to the server and you have the same setup in the cloud.

The daily workflow

Once the one-time setup is done, a normal day starts with two commands:

Shell
ssh agent-cloud
herdr

You land back in the same workspace, with every agent where you left it. When you are done, detach or close the laptop. The agents keep running. Stop them on purpose with herdr server stop.

To preview a web app that runs on the server, open an SSH tunnel from a second terminal on your laptop. For an app on port 3000, run this:

Shell
ssh -N -L 127.0.0.1:3000:127.0.0.1:3000 agent-cloud

Then open http://localhost:3000 in your browser.

If you prefer a visual interface, Cursor and VS Code both connect over SSH. Pick your agent-cloud shortcut, open a folder on the server, and you can browse files, edit them and handle commits in the editor. You can open the same Herdr session in the editor's terminal, so the agents and the file browser sit side by side.

This is the shift I describe in how programming has changed. Less time typing code, more time directing agents and reviewing what they ship. Agents that keep running while my laptop is closed fit that way of working. For the systems those agents help you build, start with how to build production AI systems. If you want to go from directing agents to designing and shipping production AI systems yourself, the GenAI Accelerator is the structured path.

The full step-by-step guide, with every command for macOS, Linux and Windows, is in the cloud workspace guide.

FAQ

Can Claude Code keep running after I close my laptop?

Yes, if it runs on a server instead of your laptop. Run Claude Code inside Herdr on a VPS, and the session keeps going when your SSH connection drops or your laptop sleeps. When you reconnect with ssh and herdr, you are back in the same session.

How much RAM does a VPS for coding agents need?

I recommend at least 8 GB. My server has 2 vCPUs, 8 GB of RAM and a 100 GB disk. The models run at Anthropic and OpenAI, so the server only needs enough for the agent sessions and your project's builds and tests.

Do the models run on my VPS?

No. Claude Code and Codex still call Anthropic and OpenAI. The VPS hosts the agent sessions, your repositories and the tools around them.

Is it safe to run coding agents on a VPS?

It can be, if you lock it down. Log in with an SSH key that only your laptop holds, run your daily work and agents as a non-root user, and restrict SSH to your own IP address with a firewall when you have a fixed IP. Understand each setup command before you run it.

Can I use Cursor or VS Code with a remote Herdr setup?

Yes. Both connect to the server over SSH. You can browse and edit files on the server, review changes, and run Herdr in the editor's terminal next to your agents.

Written by

Dave Ebbelaar

Dave Ebbelaar

Senior AI Engineer

AI engineer and founder of Datalumina. Dave helps developers build production AI systems and turn technical skills into client work.