> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Self-hosting

> Run the central server yourself, next to your hosts, on one machine or many.

The hosted central server at `api.ephemera.run` is one way to run ephemera. The other is to run `ephemera-server` yourself. It's the same program, open source, and it keeps everything on machines you control: tokens, hosts and the run history too.

Two parts run server-side:

* The **central server** (`ephemera-server`) places sandboxes on hosts and keeps track of them. It never sees your files, command output or secrets.
* A **host agent** (`ephemera-host`) runs sandboxes as Firecracker microVMs. The CLI talks to it directly to send files and stream output.

One machine can run both. Add more hosts later and point them at the same central server.

## What you need

* **An x86\_64 machine running Ubuntu 24.04**, with hardware virtualization (Intel VT-x or AMD-V) turned on. A bare-metal server, a spare PC, or a cloud VM with nested virtualization all work.
* **A private network between your laptop and the machine.** Your laptop talks to hosts over TLS, checked against each host's own key, but the central server serves plain HTTP, so the installer refuses to serve on a public address. Use a LAN, or a VPN of your choice.
* **About 2 GB of disk** for the guest image, plus room for sandboxes. Each sandbox's disk is sparse, so it takes only what the sandbox writes.

Memory sets how many sandboxes fit. An idle sandbox costs the host about 50 to 60 MB, so a 16 GB machine holds well over a hundred idle ones. Busy sandboxes use what their workload uses, up to their limit, 1 GB by default.

## Install

On the machine, from a checkout of the repository:

```bash theme={"theme":"css-variables"}
git clone https://github.com/pyjeebz/ephemera.git && cd ephemera
sudo deploy/host/bootstrap.sh --hostname ephemera-1
sudo deploy/host/install.sh
```

`bootstrap.sh` prepares the machine. It checks KVM, then installs Firecracker and Go, creates an `ephemera` user, and joins Tailscale with SSH. On a server with a public IP, run it again with `--lock-public-ssh` once Tailscale works, so the machine accepts connections only over Tailscale.

`install.sh` installs ephemera itself:

1. Builds `ephemera`, `ephemera-server` and `ephemera-host` into `/usr/local/bin`.
2. Builds the guest image into `/var/lib/ephemera/image`. This takes a few minutes and needs network.
3. Writes `/etc/ephemera/ephemera.env` with the machine's addresses. It serves on the machine's Tailscale address, or another private one with `--listen-ip`.
4. Starts both parts as systemd services, `ephemera-server` and `ephemera-host`, and waits until the host has connected.
5. Creates the first API token, named `admin`, and prints it once.

## Connect your laptop

Install the CLI and log in with the server address and the token `install.sh` printed:

```bash theme={"theme":"css-variables"}
curl -fsSL https://ephemera.run/install | sh
ephemera login --server http://100.64.0.1:7700
```

Then try it:

```bash theme={"theme":"css-variables"}
ephemera run -- echo hello from a microVM
```

If that fails, `ephemera doctor` says which step is broken, and how to fix it.

### Let your laptop reach port 7701

The host can be online in the dashboard while every run fails to connect: the host's connection goes out to the central server, but your laptop connects in to the host, on tcp:7701, so whatever sits between them must let that through: the machine's firewall, a cloud firewall, or a VPN's access rules. Or skip the network and run `ephemera` on the machine over SSH; see [Use it over SSH](/docs/guides/hosts.md#use-it-over-ssh).

`bootstrap.sh` joins the machine to Tailscale as `tag:lab`. If your tailnet has access rules that allow only SSH to that tag, a common setup, add a rule for 7701 to your tailnet policy:

```json theme={"theme":"css-variables"}
{ "action": "accept", "src": ["autogroup:member"], "dst": ["tag:lab:7701"] }
```

With the newer grants syntax, that's `{ "src": ["autogroup:member"], "dst": ["tag:lab"], "ip": ["tcp:7701"] }`. The central server's port, 7700, needs the same if your laptop logs in to it over the tailnet.

On a laptop with a small MTU, large packets can stall even when the access rules are right. WSL2, for one, can give `eth0` an MTU of 1280, which leaves no room for a VPN's own headers. Small requests get through and anything big hangs, which looks like the same "no answer". `ephemera doctor` tells the two apart. For the MTU, lower the tunnel's; on Tailscale, that's:

```bash theme={"theme":"css-variables"}
sudo ip link set tailscale0 mtu 1200
```

The setting lasts until Tailscale or the machine restarts.

## Tokens and limits

Make one token per person, laptop, agent or CI system, so each can be limited and revoked on its own:

```bash theme={"theme":"css-variables"}
sudo ephemera-server token create ci --max-sandboxes 4 --max-minutes 600
sudo ephemera-server token ls
sudo ephemera-server token revoke ci
```

`--max-sandboxes` caps how many run at once, and `--max-minutes` caps sandbox-minutes per UTC day. `ephemera-server token limits <name>` changes them later. The server picks up changes without a restart.

Every token belongs to an account, and a token only sees and destroys its own account's sandboxes. Tokens made without `--account` share the account `local`, which suits one person or a small team who trust each other. To keep people apart, give each their own account:

```bash theme={"theme":"css-variables"}
sudo ephemera-server token create sam-laptop --account sam
```

Each host belongs to the account whose join code it used, and runs only that account's sandboxes.

## Add another host

A new host joins the central server once, with a one-time code. On the server machine, make one; it works once, for 15 minutes:

```bash theme={"theme":"css-variables"}
sudo ephemera-server join-code create
```

Add `--account NAME` to join the host to that account instead of `local`. On the new machine, run the host installer, pointed at your central server:

```bash theme={"theme":"css-variables"}
curl -fsSL https://ephemera.run/host | sudo sh -s -- ej_... --server http://100.64.0.1:7700
```

It installs Firecracker, the host agent and its guest image from the latest release; see [Add a host](/docs/guides/hosts.md) for its options.

The host makes its own key, joins with the code, and from then on signs in with that key. Delete the code file afterwards; it can't be used again anyway. `ephemera-host join` prints the key's fingerprint, so you can check it against the server's logs or the dashboard.

To take a host out of an account, `DELETE /v1/hosts/<id>` with one of the account's tokens. Its sandboxes are destroyed, and it can't sign in again until it joins with a new code.

## Settings

`/etc/ephemera/ephemera.env` holds the addresses and settings. To change them, run `install.sh` again with new options rather than editing the file:

| Option | Meaning |
| - | - |
| `--listen-ip IP` | Serve on another private address instead of the Tailscale one |
| `--name NAME` | The host's name in its account, in records and in `ephemera ls`. Set when the host joins |
| `--host-args "..."` | Extra `ephemera-host` flags, such as `--capacity 40` (default 20), `--max-lifetime 8h` (default 24h) or `--max-snapshot-bytes` (default 20 GB) |
| `--skip-image` | Don't build the guest image; it must already be in `/var/lib/ephemera/image` |

Upgrades, logs, benchmarks and where everything lives: [Self-hosting reference](/docs/self-hosting/operate.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.