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

# Add a host

> Bring a Linux machine with KVM, join it to your account with a one-time code, and manage it.

A host is a machine you own that runs your sandboxes as Firecracker microVMs. Add as many as you like; each sandbox goes to the connected host running the fewest, among those with room.

## What a host needs

* **x86\_64 Linux with KVM.** Ubuntu 24.04 is what ephemera is tested on. Check with `ls /dev/kvm`. A bare-metal server, a spare PC, or a cloud VM with nested virtualization all work.
* **About 2 GB of disk** for the guest image, plus what sandboxes write. Each sandbox's disk is sparse: it takes only what's written.
* **Memory** sets how many sandboxes fit. An idle sandbox costs about 60 MB, so a 16 GB machine holds well over a hundred idle ones. A busy one uses what its workload uses, up to its limit, 1 GB by default.
* **A way to reach it.** The host connects out to the central server by itself and needs no open port for that. But the machine you run `ephemera` on sends files and reads output straight from the host, on port 7701. Any of these works:
  * the same LAN as your laptop,
  * a VPN you already use, with tcp:7701 allowed to the host,
  * the machine's public address, with a firewall that lets in only your own address,
  * no network at all: SSH into the machine and run `ephemera` there. See [Use it over SSH](#use-it-over-ssh).
  * or make your laptop the host: see [Run it on one machine](/docs/guides/one-machine.md).

## Join it to your account

**1. Make a join code**

In the [dashboard](https://ephemera.run/dashboard/hosts), under Hosts, choose **Make a join code**. It looks like `ej_` and 26 letters and digits, works once, and lasts 15 minutes.

On a [central server you run](/docs/self-hosting.md), make one with `sudo ephemera-server join-code create` instead.

**2. Install the host agent**

On the machine, with the code at the end:

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

It checks KVM, installs Firecracker and the host agent from the latest release, checking each download against its checksum, and builds the guest image (a few minutes; it downloads Ubuntu's packages). Then it joins your account with the code and runs the agent as the `ephemera-host` systemd service. It sets up no network of its own.

Your laptop reaches the host at the machine's private address. With exactly one, the installer uses it; with several, such as a LAN address and a VPN address, it lists them and asks you to pick one with `--address`:

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

A public address works too, such as a rented server's, but then the host's port, 7701, is open to the internet. The host serves TLS with its own key and checks each sandbox's token, but it's safer to let only your own address through the firewall. Or pass `--address 127.0.0.1` and use ephemera on the machine itself, over SSH.

**3. Check it**

The installer prints the host's key fingerprint when it joins, then waits until the host is connected:

```text theme={"theme":"css-variables"}
Key fingerprint: SHA256:qL3HdSf8UZXKjpVRma/Eo9jyxni9zZ8p6aDu+FxTJhA
```

The dashboard shows the host online, with the same fingerprint. From your laptop:

```bash theme={"theme":"css-variables"}
ephemera hosts
```

```text theme={"theme":"css-variables"}
NAME   ID             ONLINE  LAST SEEN  KEY                                                 PINNED
lab-1  host_0b275ef1  yes     now        SHA256:qL3HdSf8UZXKjpVRma/Eo9jyxni9zZ8p6aDu+FxTJhA  not yet; on first use
```

For a host that's offline, LAST SEEN says when it last checked in, such as `4 days ago`.

Delete the code file afterwards. It can't be used again anyway.

## Use it over SSH

If you work on the machine over SSH anyway, run ephemera there too, and skip the network: with `--address 127.0.0.1`, the host listens only on the machine itself, and nothing is open to anyone else.

```bash theme={"theme":"css-variables"}
curl -fsSL https://ephemera.run/host | sudo sh -s -- ej_... --address 127.0.0.1
curl -fsSL https://ephemera.run/install | sh
ephemera login
```

`ephemera login` prints a code and a page to open. Open it on any device, such as your laptop, and approve. Then run `ephemera` from a checkout on the machine. Changes you make on your laptop need to reach that checkout first, with git or rsync.

`ephemera dev` forwards the sandbox's ports to the machine's own localhost. To open one in your laptop's browser, forward it over SSH as well:

```bash theme={"theme":"css-variables"}
ssh -L 3000:127.0.0.1:3000 you@the-machine
```

A host on another address works over SSH the same way; `127.0.0.1` just keeps everything else out.

## Already have ephemera-host

To join a machine that has the binary:

```bash theme={"theme":"css-variables"}
sudo ephemera-host join --server https://api.ephemera.run ej_...
```

It makes the host's key in `/var/lib/ephemera/host.key` if there isn't one, joins, and saves what it joined as in `/var/lib/ephemera/host.json`. From then on the host signs in with that key; there's no shared secret. `--name` sets its name in your account; the default is the machine's hostname.

## Keys and pinning

Every host has an Ed25519 key. It signs the host in, makes the host's TLS certificate, and signs its records. The first time your CLI uses a host, it checks the key against the central server's record and pins it. If the key changes later, the CLI refuses the host until you accept it:

```bash theme={"theme":"css-variables"}
ephemera trust lab-1
```

Do that only when you know why it changed, such as a rebuilt machine.

## Settings

Pass host agent flags through the installer, for example:

```bash theme={"theme":"css-variables"}
curl -fsSL https://ephemera.run/host | sudo sh -s -- --host-args "--capacity 40 --max-lifetime 8h"
```

| Installer option | Meaning |
| - | - |
| `--address IP` | The address your laptop reaches this machine on |
| `--name NAME` | The host's name in your account. Default: the machine's hostname |
| `--server URL` | The central server to join. Default: `https://api.ephemera.run` |
| `--host-args "..."` | Extra host agent flags, below |
| `EPHEMERA_VERSION=vX.Y.Z` | Install that release instead of the latest |

These host agent flags are the ones you're most likely to want:

| Flag | Default | Meaning |
| - | - | - |
| `--capacity` | 20 | Most sandboxes on this host at once |
| `--max-lifetime` | 24h | Destroy any sandbox this long after it was made |
| `--max-snapshot-bytes` | 20 GB | Space for [setup snapshots](/docs/guides/setup.md) |

The [host reference](/docs/reference/host.md) lists every flag.

## Upgrade a host

Run the installer again, without a code:

```bash theme={"theme":"css-variables"}
curl -fsSL https://ephemera.run/host | sudo sh
```

It keeps the host's key, name, server and address, installs the latest release, and rebuilds the guest image when the guest agent changed. It restarts the host agent only if something changed, and a restart destroys the sandboxes running on it, so upgrade when none are in use.

## Remove a host

In the dashboard, under Hosts, choose **Remove**. Its sandboxes are destroyed, and it can't sign in again until it joins with a new code. With a token instead: `DELETE /v1/hosts/<id>`, see the [API reference](/docs/reference/api.md).

To take ephemera off the machine itself:

```bash theme={"theme":"css-variables"}
curl -fsSL https://ephemera.run/host | sudo sh -s -- --uninstall --purge
```

Without `--purge`, it keeps the host's key and guest image in `/var/lib/ephemera`.


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