SabaKore

Home / Articles / AI guides

Running an AI Coding Agent Like Claude Code on a VPS

A look at what changes when you put an AI tool that reads, writes and runs code from the terminal on a VPS. It covers how to think about memory and how to limit what the agent is allowed to execute.

Ren, a junior infrastructure engineer

Ren

Some people seem to run tools like Claude Code, where an AI edits code and runs commands from the terminal, on a VPS. What actually changes?
Procura, a cloud AI robot who explains

Procura

With those tools, the requests to the model go over the internet, but the part that reads code, edits it and runs commands lives on the machine where you opened the terminal. If you put that terminal on the VPS, the place where everything runs changes completely.

Advantages of putting it on a VPS

  • Work keeps going even after you close your terminal (you can keep it running with tmux or screen)
  • You can connect over SSH from your phone and keep giving instructions while you're out
  • A team can share the same environment, so everyone gets the same results
  • You don't use your own laptop's CPU or battery
Ren, a junior infrastructure engineer

Ren

But the AI company's servers do all the heavy lifting, right? So I don't need to care much about the VPS specs?
Procura, a cloud AI robot who explains

Procura

That's an easy thing to get wrong. The part where the model thinks does run on their servers, but actually building the code, running tests and producing diffs with Git is still the VPS's job, just like usual.

How to think about memory

What decides how much memory you need is the project itself, not the AI tool. The build system, the amount of dependencies and the number of tests you run at once all change the requirement. When memory runs short, the result is the same as in normal development: processes get killed partway through a build or a test run. Start by checking that your current project builds without problems on the plan you are considering.

  • If you only handle lightweight scripts, a smaller plan is often enough
  • Setups that use Next.js or Docker tend to have heavy builds, so plan for a plan with room to spare in memory
  • If you run several tests or builds at the same time, add that much on top when estimating

How to limit what the agent can execute

Wilson, the security guard

Wilson

Hmm, a tool that reads code, rewrites it and even runs commands. What if that tool ran a trap I planted, say an instruction I slipped into a library it pulled in? What would happen then?
Procura, a cloud AI robot who explains

Procura

That has the same structure as prompt injection (an attack that hides instructions in text you feed to the AI). Any code or document an AI agent reads can be an input from outside. So you need to narrow what it can execute from the start.
  • Don't run it as root. Have it work as a dedicated regular user
  • Always look over the diff yourself before running a proposed change
  • Make a backup or a commit before you start, so you can roll back if something breaks
  • Be extra careful when you let it read code imported from outside

Protecting the SSH connection itself

Before you think about the AI tool's safety, the SSH connection underneath has to be protected. If password authentication is still on, even a carefully designed permission setup for the AI tool means little. Switching to key authentication and limiting the source of connections with a firewall are basic steps to finish before installing any AI-related tools.

Procura, a cloud AI robot who explains

Procura

When you try a new tool, it's reassuring to firm up the foundation first. If you've done all that, you're ready to leave an AI agent running.
Ren, a junior infrastructure engineer

Ren

So even if the model's computation is handled on their side, how well the place it runs is protected is up to me.

This article is translated from the Japanese original. If the two differ, the Japanese version is the one we keep up to date.