Skip to content
Guides · Coding agents

Run Claude Code in a cloud VM

Updated October 24, 2026 .md

Short answer: Create a cloud Ubuntu VM with Claude Code already installed, give it your Anthropic key, then prompt it from your laptop or SSH in and run claude. The VM keeps working when your laptop sleeps, and stopping it saves memory so the session resumes where it left off.

At a glance#

Topic Detail
What you get A Cloud Hypervisor microVM: Ubuntu 24.04, root via sudo, systemd, Docker, /dev/kvm
Claude Code Preinstalled in every sandbox (also Codex, OpenCode, Pi, Kimi Code, Mistral Vibe)
Credentials Your own Anthropic API key, added once on the dashboard's Agents page
Size used below default: 4 vCPU, 8 GB RAM, 50 GB disk, $0.036/hour, billed per second
When it's stopped Costs nothing; resume brings back memory and running processes
Previews Any port becomes an HTTPS URL with sbx host

1. Install the CLI and sign in#

curl -fsSL https://sandboxer.com/install | sh

The installer puts sbx on your PATH and runs sbx onboard, which signs you in through the browser. New accounts start a 7-day trial with 25 hours of machine time (card required). On Windows, use irm https://sandboxer.com/install.ps1 | iex.

2. Add your Anthropic key#

Open the dashboard's Agents page and add an Anthropic API key. Sandboxes started from your environment get it automatically, so Claude Code is signed in when the VM starts. For this integrated agent, sign-in with a Claude subscription isn't supported yet, so use an API key. (In your own SSH session, /login works as usual; see step 4.)

If you start a sandbox with --no-env (none of your secrets), pass a key just for that sandbox instead:

sbx new --no-env -e ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY"

3. Create the VM#

sbx new

It's ready in seconds and prints the sandbox id (like sb_k3v9x2mq), its URL and its size. Check that Claude Code is there:

sbx exec sb_k3v9x2mq "claude --version"

4. Give Claude Code work#

From your laptop, without a terminal session. sbx prompt sends a task to the agent inside the VM and returns at once. The agent runs in /home/user with the sandbox's environment.

sbx prompt sb_k3v9x2mq --provider claude-code "Clone github.com/acme/api, run the tests and fix the failures"
sbx events sb_k3v9x2mq --follow     # stream what it's doing
sbx steer sb_k3v9x2mq "Skip the integration tests"

The same call is a plain HTTP request, so a script or another agent can do it:

curl -sS -X POST https://sandboxer.com/api/v1/sandboxes/sb_k3v9x2mq/prompt \
  -H "Authorization: Bearer $SANDBOXER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"provider":"claude-code","prompt":"Run the tests and fix the failures"}'

Interactively, the way you use it locally. SSH in and start claude. tmux is installed, so the session survives a dropped connection.

sbx ssh sb_k3v9x2mq
tmux new -s claude
claude

If Claude Code says Not logged in · Please run /login, sign in with /login the way you would on any machine, or set your key in that shell with export ANTHROPIC_API_KEY=….

5. Keep it running, or pause it#

A new sandbox stops itself after one hour as a safety net. For a long task, extend it or turn auto-stop off:

sbx extend sb_k3v9x2mq --hours 12
sbx extend sb_k3v9x2mq --no-auto-stop

When you're done for the day, stop it. Stopping saves the VM's memory as well as its disk, and a stopped sandbox costs nothing:

sbx stop sb_k3v9x2mq
sbx resume sb_k3v9x2mq     # tmux, the dev server and the claude session are still running

6. See what it built#

If Claude Code starts a dev server, put the port on an HTTPS URL. It's private with a token by default, or public with --public:

sbx host sb_k3v9x2mq 3000

Run several at once#

Each sandbox is its own VM, so you can give every task its own copy. Set one up the way you like, save it as a named snapshot, and start new VMs from it:

sbx snapshot sb_k3v9x2mq my-repo-ready
sbx new --from my-repo-ready

FAQ#

Can I run Claude Code on a virtual machine?#

Yes. Claude Code runs on Linux, and a Sandboxer sandbox is a full Ubuntu 24.04 VM with Claude Code already installed, so there's nothing to set up beyond signing in.

Is it safe to let Claude Code run without permission prompts in the VM?#

It's much safer than on your own computer, because the agent can only touch what's inside that VM. Start it with --no-env and only the keys the task needs, so a mistake can't reach your other secrets. See Claude Code without permission prompts.

Does the VM keep working when my laptop is closed?#

Yes. The agent runs in the cloud VM, not on your laptop. Use sbx prompt or a tmux session over SSH, and check back later with sbx events or sbx ssh.

What does it cost?#

The default size (4 vCPU, 8 GB) is $0.036 an hour, billed per second while it runs. A stopped sandbox costs nothing. Your Anthropic usage is billed by Anthropic on your own key.

Can I use my Claude Pro or Max subscription instead of an API key?#

For sbx prompt and the API, not yet: the integrated agent uses an API key you add on the Agents page, and subscription sign-in is coming. In your own SSH session, Claude Code's /login works as it does on any machine.

More guides

Top AI sandbox platforms for code execution in 2026, ranked

For running AI-written code we rank Sandboxer, Freestyle and E2B first: each gives code its own VM with an API or SDK and can pause with memory. Pick Daytona for Windows or GPUs, Modal or Northflank for GPUs at scale, E2B or Northflank to run in your own cloud, and Vercel Sandbox if your app lives on Vercel.

Read the guide
Best sandboxes for running coding agents (Claude Code, Codex, Gemini CLI) in 2026, ranked

For coding agents we rank Sandboxer first: a full Ubuntu VM with Claude Code and Codex preinstalled, Docker, and stop-and-resume that keeps the agent's session in memory. Freestyle and Amp Orbs also keep memory across pauses. Pick E2B for prebuilt agent templates on open source, Docker Sandboxes for free local runs, and Codespaces if you live in GitHub.

Read the guide
Best Daytona sandbox alternatives in 2026, ranked

The best Daytona alternatives depend on why you're switching. For a full Linux microVM on every sandbox with memory-saving stop and Docker, we rank Sandboxer first. E2B suits open source and self-hosting, Modal massive short-job fleets, Northflank bring-your-own-cloud with GPUs, and Vercel Sandbox apps on Vercel.

Read the guide
Best E2B alternatives in 2026, ranked

If you're leaving E2B for longer sessions or a fuller machine, we rank Sandboxer first, then Freestyle: both give each sandbox a full Linux VM that keeps memory across pauses, with Docker and no short session cap. Pick Daytona for Windows or GPUs, Northflank for bring-your-own-cloud, and stay on E2B if you need open source.

Read the guide