SSH into sandboxes for AI agents
Point the tools you already use at a sandbox: ssh for a shell, scp and sftp for files, ssh -L for a port. Every sandbox answers SSH with nothing to install, and logging in wakes a paused one exactly where it was.
- A microVM per sandbox
- Starts in 0.15 s
- $0.018/h, billed per second
How to SSH into a sandbox
Add your public key once
Give the workspace your key with
set_ssh_keysor in the web console’s settings. It opens every sandbox you have and every one you make later.Take the sandbox’s command
Each sandbox carries its whole SSH command as
ssh_command. Or runpethost sandbox shell, which signs in for you without a key.Work as on any server
You get a shell with passwordless sudo,
scpandsftpfor files of any size, andssh -Lto open a port of the sandbox on your own computer.
from pathlib import Path
from pethost.sandboxes import Sandboxes
sandboxes = Sandboxes() # reads PETHOST_TOKEN
key = Path("~/.ssh/id_ed25519.pub").expanduser().read_text()
sandboxes.set_ssh_keys(ssh_keys=[key]) # replaces the workspace's keys
box = sandboxes.create_sandbox()
print(box.ssh_command)
# ssh [email protected] -p 2222pethost sandbox shell k3x9q2m7v1c8p4ra # signs in with a token, no key needed
scp -P 2222 results.csv [email protected]:/home/user/
ssh -p 2222 -N -L 5432:localhost:5432 [email protected]Why SSH into a Pethost sandbox
Nothing to install
Every sandbox answers SSH, from our template or one you saved. You never add an SSH server or open a port inside it.
A login wakes it
Log in to a paused sandbox and it wakes in about 0.1 s with its memory and processes as they were. It stays awake while your session is open.
A key or a token
The workspace’s keys open every sandbox. A program that holds no key signs in with a token from
connect_sandbox, valid for an hour by default and a day at most.Private ports on your laptop
ssh -L 5173:localhost:5173opens a dev server atlocalhost:5173in your browser without making its port public, and the same reaches a database the sandbox keeps to itself.Files of any size
scpandsftpcarry what an API call cannot, both ways, with the tools you know.One history for agent and person
What you run over SSH shows among the sandbox’s commands and events, marked as started by SSH, beside everything the agent ran.
What teams use it for
Debugging an agent’s run
Log in to the sandbox where an agent’s tests failed, with its files and processes as it left them, and see what it saw.
Working beside an agent
Open a shell in the same sandbox while the agent works in it: watch its processes, fix a file, or take over.
Moving data in and out
Copy a dataset in before a run and the results out after it with
scp, or reach a Postgres inside the sandbox from your own tools overssh -L.
Limits and prices
SSH has no price of its own: the sandbox is billed by the second at its size’s price, $0.018 an hour for SMALL (2 vCPU, 4 GiB), and keeps running while a session is open. Port 2222; forwarding is local only and reaches the sandbox’s own ports, so ssh -R is refused. A stopped sandbox asks to be resumed first, unless you set it to wake when stopped.
A connection token is a root credential: give it to a program, never put it in a web page. Removing a key from the workspace ends that key’s sessions.
How it compares
On 21 November 2026, E2B reached a sandbox’s shell through a WebSocket proxy. boat.dev has SSH but no pause: after a stop, its docs say a resume within 10 minutes “usually gets the same machine back, with memory and running programs. Do not count on it.” Here a paused sandbox keeps its memory and processes, and an SSH login wakes it.
Every sandbox, in numbers
Pethost Agent Sandboxes are cloud VMs for AI agents. Each is a Firecracker microVM with its own kernel and root inside: it starts in about 0.15 s, pauses with its memory while the agent thinks, and wakes at the next call. Billed by the second, in the EU.
- ~0.15 s to start a sandbox from a template
- ~0.1 s to wake a paused one, memory and processes as they were
- $0.018/h for 2 vCPU, 4 GiB and 10 GiB while running
- 1 s billing step: each run rounded up to a second, 10 s at least
- $0 to create or start a sandbox
Measured on our servers on 18 November 2026, through an API 16 ms away: a create’s median 123 ms (SMALL) to 158 ms (XLARGE), a resume 124 ms, a command to a paused sandbox 80 ms.
Questions
Do I need sshd in my template to SSH into a sandbox?
No. Every sandbox answers SSH, from our template or one you saved, with nothing installed in it.
Which port?
2222, as the sandbox’s ssh_command says.
Does an SSH session keep the sandbox awake?
Yes, while it is open. Once it closes, the sandbox’s idle timers run again: by default it pauses after 5 minutes.
Can I copy files?
Yes, with scp or sftp, or through the API: write_files for up to 17 MiB, a download or upload link for any size.
Can a program sign in without a key?
Yes, with a token from connect_sandbox as the password. It lasts an hour unless you ask for up to a day, and revoking the sandbox’s tokens makes it stop working.
Everything else a sandbox does
- Code execution in one callRun the code your model writes and get its exit code and output in one call, stream long jobs, edit files by exact replacement, and open a terminal in the browser.
- A URL for every portA dev server on port 3000 answers at its own HTTPS address, public or behind a token, and a visit wakes a paused sandbox in about 0.2 s.
- A microVM with its own kernelEach sandbox is a Firecracker microVM with its own Linux kernel and root inside: install anything, run Docker, change any file. It starts in about 0.15 s.
- Pauses with its memoryA paused sandbox keeps its memory, processes and files at 30% of the price, and the next call wakes it in about 0.1 s, exactly where it was.
- Pauses itself when idleFive minutes without a call and a sandbox pauses, memory kept; thirty and it stops, files kept. Every timer is set per sandbox, and 0 turns it off.
- Billed by the second, starts freeRunning time by the second from $0.018 an hour, paused time at 30% of that, a stopped sandbox by the GiB of its own files. Creating and starting one cost nothing.
- Claude Code and Codex, installedClaude Code, Codex and OpenCode run in every sandbox with every permission: one call gives one a prompt, another streams each tool call, and your API key stays outside.
- A desktop with ChromeEvery sandbox has a 1280×800 screen with Chrome: click, type and screenshot in one call, drive it with Playwright or Puppeteer, or watch it live and take over.
- Save a sandbox as a templateSet a sandbox up once and save it as a template, packages and Docker images included; start as many sandboxes as you need from it, each in about 0.22 s.
- Only the hosts you allowList the domains, IPs and ports a sandbox may reach: every other host is refused, even in DNS, and a change applies while it runs.
- API keys the sandbox never holdsCode in the sandbox sees a placeholder. Its requests still work: the real API key is put in on the way out, only to the hosts you name.
- See everything a sandbox didCPU, memory, disk and network for 24 hours, and every change of state, command, host reached and agent turn, as a list or a live stream.
Give your agent a computer in 0.15 s
From $0.018 an hour for 2 vCPU and 4 GiB, billed by the second. Paused, 30% of that. Starting one is free.