Sandboxes
Run releases in sandboxes on your own host or in your AWS account, reach them over Tailscale SSH, and preview dev servers.
A sandbox is an isolated environment for one release. Agents run inside it, so a release works in its own virtual machine instead of directly on your Mac. A plan with sandboxes is needed. See Plans and limits.
There are two kinds:
- Self-hosted sandboxes run on a Linux server you own, called a sandbox host.
- Cloud sandboxes run as boxes in your own AWS account.
A sandbox pauses after 15 minutes without a live run and resumes when work returns. A paused sandbox that nobody resumes is deleted after 7 days.
Agents inside a sandbox have no sudo. On a self-hosted host, that holds for sandboxes created by host agent 0.2.11 or newer. A sandbox made by an older host agent keeps sudo until you recreate it. Cloud sandboxes never gave agents sudo. Root access is only over Tailscale SSH.
Self-hosted sandbox hosts
A sandbox host is a dedicated Linux machine that runs sandboxes as small virtual machines. It counts as a machine on your plan.
Requirements
- A dedicated Linux x86_64 machine with
/dev/kvmand/dev/net/tun. - Kernel 6.8 or newer with 4 KiB pages, cgroup v2, and glibc 2.34 or newer.
- Docker 27 or newer, Docker Compose 2.24 or newer, and nftables.
- At least 12 GiB of RAM and 40 GiB of free disk.
- Outbound HTTPS to the image registries, GitHub and
pkgs.tailscale.comwhile installing, and to your Kairoku API while running. The host and its sandboxes must be able to reach the API's HTTPS address.
The installer replaces /etc/nftables.conf with rules that block inbound traffic and stop sandboxes reaching the host, private networks and cloud metadata addresses. Run it only on a host where that is what you want.
Install and pair
- Unpack the sandbox-host bundle on the host and run its
install.shas root. It pulls the images and starts the stack. - Build the guest template, as the bundle's guide describes. Wait for
template kairoku-guest built. - In the desktop app, open Machines, choose Sandbox host under Add a machine, and choose Get a code.
- Run the command the app shows on the host. It enrolls the host agent with the one-time code.
- Set the host's capacity above zero. A new host starts at zero and takes no sandboxes until you do. After the host's first heartbeat, call
sandboxHost.setCapacityon your Kairoku API with a positivemaxVms, as the sandbox-host guide describes.
The host agent then polls Kairoku. Sandbox hosts need a plan with sandboxes. The Sandbox host choice is locked without one.
Keep it up to date
If a sandbox says its host agent doesn’t support SSH; update the bundle, install a newer sandbox-host bundle on that host.
If it shows Rebuild the guest template to add SSH, build the guest template again from the newer bundle. Both are needed for Tailscale SSH and Preview.
Harden the host
The host is your server, and securing it is your job. Close port 22 on the host yourself, or limit it to addresses you trust. Sandboxes don't need it, and Tailscale SSH reaches a sandbox without it.
Cloud sandboxes on AWS
With cloud sandboxes, each sandbox is one EC2 box in your own AWS account. Kairoku creates, pauses and deletes the boxes. You pay AWS for them directly. This needs a plan with cloud sandboxes.
Each box runs Ubuntu 24.04 on a Graviton t4g instance, t4g.medium by default. It has a 30 GiB disk and one public IPv4 address. Its security group allows no inbound traffic.
What it costs you
AWS bills your account. The prices below are for t4g.medium in us-east-1, and other regions differ slightly.
- A running box costs $0.0336 an hour, plus $0.005 an hour for its public IPv4 address.
- A stopped box still costs about $2.40 a month for its disk.
- CPU above the baseline is billed too, up to about $0.064 an hour per box at sustained full CPU.
- Each box is also one device on your Tailscale plan.
Idle boxes stop after 15 minutes. The setup screen shows these costs per box, and the CPU ceiling times the number of boxes you can run, before it creates anything.
Set it up
- Install the AWS CLI v2 on your Mac and sign in to the AWS account you want to use. You need rights to create IAM roles and CloudFormation stacks there.
- Open Settings → Connections → Cloud sandboxes (AWS). The same steps are under Machines → Add a machine → Cloud (AWS).
- Begin. Enter a region and choose Begin.
- Profile. Pick an AWS profile, then choose Check account. The profile is used only by the AWS CLI on your Mac. Kairoku never sees its credentials.
- Verify account. Check the account and ARN shown. Tick This is the AWS account Kairoku may create sandboxes in.
- Create stack. The app creates a CloudFormation stack and narrates its progress, for example "Vpc CREATE_COMPLETE (3/14)". The stack holds the network and a role that lets Kairoku manage tagged boxes.
- Connect. Kairoku checks that it can reach your account. This takes a few seconds. The fleet then shows Ready, with how many boxes it can run at once and your account's vCPU quota.
If your account's vCPU quota fits fewer boxes than your plan allows, the app tells you. Ask AWS for a quota increase.
If the AWS CLI isn't installed, the app shows the create-stack command to run yourself in a terminal signed in to the right account. Then choose I created the stack and enter your 12-digit account ID.
If the stack ends in a failed state, the app shows the reason. Choose Delete the failed stack and try again.
Remove it
Choose Remove… next to the fleet. Kairoku deletes every cloud sandbox and its box. The app then offers Delete stack, which removes the network resources from your account. Run it to remove the network and roles Kairoku created.
If Kairoku loses access to your account, the app says so and that some boxes may still be running. A box whose sandbox has ended stops by itself. A box whose sandbox is still live keeps running, and AWS keeps billing it, until Kairoku has access again or you end it in the AWS console. Restore access first if you can, then choose Remove…. Otherwise terminate those boxes in the AWS console. Stopped boxes still cost for their disk until you terminate them there.
What pausing does
A cloud sandbox pauses by stopping its box, and resumes by starting it again. Processes that were running, such as a dev server, don't survive a pause. A stopped box has no public address and gets a new one when it starts.
Tailscale SSH
You can open a root shell in any sandbox, self-hosted or cloud, over Tailscale SSH. You connect your own tailnet once. Each sandbox then joins it as one tagged device named kai- and an ID, and Kairoku removes the device when the sandbox ends. This needs a plan with Tailscale SSH.
Self-hosted sandbox hosts themselves don't join your tailnet, only their sandboxes do. A sandbox can't start connections into your tailnet.
Connect your tailnet
Open Settings → Connections → Tailscale. It shows three steps.
- Paste into your tailnet policy file. Copy the snippet the app shows into your Tailscale policy file and save it. It defines the
tag:kairoku-sandboxtag, lets your tailnet members reach it on port 22 only, and allows SSH as root and as a regular user. - Create an OAuth client. In the Tailscale console, under Trust credentials, create an OAuth client. Give it
auth_keys(write) anddevices:core(write), both taggedtag:kairoku-sandbox, pluspolicy_file(read) withdevices:core:readanddevices:posture_attributes:read. - Paste the client ID and secret, then choose Connect…. Kairoku checks them by using them. It stores the secret encrypted and never shows it again.
Kairoku never edits your policy. You edit it in the Tailscale console.
Tailnets that start allowing everything
A new tailnet allows every connection by default. Kairoku refuses to add sandboxes while any rule lets a sandbox start a connection, so replace the default rule. The app gives the replacement, which lets members reach each other's own devices and nothing else:
{"action":"accept","src":["autogroup:member"],"dst":["autogroup:member:*"]}Tagged devices, sandboxes included, can then no longer start connections. Members no longer reach your other tagged devices until you add rules for them.
A wider rule, "dst": ["*:*"], lets members reach every port on every sandbox with no re-authentication. In a self-hosted sandbox that includes dev servers and databases listening on localhost. Keep 22 the only port granted to tag:kairoku-sandbox.
If your policy is open, the card shows Policy needs a fix and lists what it found. Existing sandboxes stay on the tailnet. Fix the policy to add new ones. Kairoku checks again every 6 hours, and when a sandbox tries to join and the last check is more than 10 minutes old.
Things to know
autogroup:membermeans every member of your tailnet. Anyone that rule covers can SSH to a sandbox as root, even if Kairoku has locked them out of the workspace.- Each sandbox is one device on your Tailscale plan. Tailscale's Personal plan is for non-commercial use. Tailscale's pricing page lists "Basic Tailscale SSH: up to 5 hosts", so check whether your plan limits SSH hosts before you run more than 5 sandboxes.
- If your tailnet uses Tailnet Lock, a sandbox that joins needs signing in your Tailnet Lock settings.
Open a shell
- Install Tailscale on your Mac and connect to the same tailnet as your sandboxes.
- Open the release's settings, find its sandbox, and choose Connect over SSH.
- Wait for the sandbox to join. Then copy the command, or choose Open in Terminal.
The command uses your system ssh as root. Kairoku refuses to open a shell if your Mac is on a different tailnet from the sandbox, or if it can't tell which tailnet your Mac is on. It does not forward your SSH agent into the sandbox.
In an interactive root shell on a self-hosted sandbox, /usr/local is not on the PATH on purpose, so npm isn't either.
Keep Kairoku open. The app keeps the sandbox awake while the SSH panel is open, and for 60 minutes after Open in Terminal. The sandbox can pause about 10 minutes after the app closes, which ends the session.
Disconnect
Choose Disconnect… on the Tailscale card. Kairoku removes every sandbox from your tailnet and shows "Removing N devices" while it works. Running sandboxes keep running without SSH.
Preview a dev server
Preview opens a dev server that runs in a sandbox in your browser. It needs Tailscale SSH to be working for that sandbox.
- Start the dev server in the sandbox, for example on port 3000.
- In the sandbox's SSH panel, enter the port under Preview a dev server and choose Open preview.
- The app opens an
ssh -Ltunnel in Terminal and openshttp://localhost:<port>in your browser when it is ready. The local port is the sandbox port, or the next free one if that is taken. Ports below 1024 are shifted up by 8000.
The page opens on localhost, so it behaves like local development. Service workers, clipboard access, hot reload and OAuth redirects registered for localhost all work. The tunnel logs in as a regular user, not root, and only goes from your Mac to the sandbox.
Each click opens a new tunnel in a new Terminal window. Close the window to end it.
If the page doesn't load, nothing is listening on that port in the sandbox yet. After a pause, open the preview again. Cloud sandboxes also lose running processes when they pause. If the tunnel doesn't come up within 2 minutes, look at the Terminal window. A Tailscale re-authentication prompt may be waiting there.
Preview is for you. A phone or a teammate can't open it without running their own tunnel.