# Install Hermitbox

> Let your agent do it: Install Hermitbox on this Linux machine. Run `curl -fsSL https://hbx.sh | sh` on `x86_64` or `aarch64` as my ordinary user, never with sudo, unless I ask for the server or node preset. If I want to see the plan first, run `hermitbox up --check`. Then run `~/.local/bin/hermitbox run -- echo hello` and show me the output. The installer saves the API URL and key privately, so never copy the key into a config file or this chat. Follow the exact steps in https://docs.hermitbox.dev/v0.3.2/get-started/install.md.

One command installs and starts Hermitbox on Linux (`x86_64` or `aarch64`), as your own user,
with no root and no Docker. The installer asks nothing. It prints the API URL and saves the URL
and key privately; `hermitbox config key` prints the key.

```sh
curl -fsSL https://hbx.sh | sh
```

Check that it works:

```sh
~/.local/bin/hermitbox run -- echo hello
```

The installer looks at the host and takes the preset for it: a named setup for an ordinary user,
a server with root, a container or a fleet node. `hermitbox up --check` prints the plan without
changing anything. `--preset user|container|server|node` overrides what the installer detected.

## User preset

An ordinary account gets the user preset, which needs no sudo, Docker or system manager. The
release bundle is signed with the ML-DSA-65 release keys. It includes PostgreSQL, RustFS, control,
edge, `hermitboxd` and its agent.

The installer takes the release built for the host's machine. On `aarch64`, `wasm`, `vm` and the
native process tools are off and say why: their pinned agentOS sidecar, VM bundle and tool bundle
are built for `x86_64`.

Data, configuration, state and runtime sockets follow absolute XDG paths below home. The defaults
are:

- `~/.local/share/hermitbox`
- `~/.config/hermitbox`
- `~/.local/state/hermitbox`
- `~/.cache/hermitbox-runtime/hermitbox`

Hermitbox refuses an XDG path that escapes home. The runtime falls back below home when
`/run/user` is outside it.

The service listens on loopback port 7331, or on another free unprivileged port when 7331 is busy.
Sandboxes use authenticated path aliases, so you don't need a domain.

Process isolation needs enforceable Landlock ABI 3. Without it, on an `x86_64` host with glibc,
the user preset selects Wasm instead and says so. On any other host, `aarch64` included, the
installer stops and says what the host lacks, unless a usable container engine lets it
start with containers. Hermitbox refuses any unsupported backend you request by name.

When systemd user services and linger are available, Hermitbox installs and starts
`~/.config/systemd/user/hermitbox.service`. Otherwise it runs in the background, in a session of
its own, and keeps running after you log out. After the machine restarts, run `hermitbox up` to
start it again. Its output is in `~/.config/hermitbox/supervisor.log`.

New POSIX shells find `hermitbox` through a managed `PATH` block. Hermitbox leaves read-only,
unsafe or symlinked shell profiles untouched. The absolute path works in the current shell.

On a terminal the installer shows each step with its progress and time, then a short summary: the
API URL, the tiers that are on, each tier that is off with what would turn it on, and the command to
run next. `hermitbox doctor` lists every capability. Piped into a file or run by CI, the output
is plain lines and the summary is a JSON record. `NO_COLOR` turns colour off.

Process sandboxes share your UID, so use them for work you trust. The setup summary reports
whether the managed service supports [process memory and CPU limits](https://docs.hermitbox.dev/v0.3.2/reference/process-tier.md#limits).

### Upgrade or remove

- `hermitbox upgrade` authenticates the latest release and keeps state and credentials.
  Deployment requirements stay in place across user-manager restarts and upgrades. A backend
  change needs an explicit data migration.
- `hermitbox down` stops the service and its retained compute, and keeps data.
- `hermitbox down --purge` also removes the managed bundle, configuration, state, cache,
  bootstrap, CLI shortcut, exact `PATH` block and user unit. It prints the removed paths. It
  reverses linger only when this installation enabled it. Save backups before purging.

## Server with root

Root on a systemd host, outside a container, gets the server preset. For a public domain, point a
DNS A record at the server and allow inbound TCP 443 for HTTPS and certificate validation. The edge
needs local TCP ports 80 and 443 for its HTTP and TLS fronts.

```sh
curl -fsSL https://hbx.sh | sudo HERMITBOX_DOMAIN=sandboxes.example.com sh
```

The server gets Docker, nftables, persistent Docker volumes for the database and object store,
control and edge units, and its enrolled local node. On `x86_64` it also gets the release's
agentOS distribution, so its node serves wasm sandboxes beside containers. On Debian and Ubuntu
the installer can add missing packages itself. Other distributions need Docker and nftables
installed first, and the installer names them before it provisions anything.

Server sandbox placement needs private network and PID namespaces and enforced CPU and memory
limits. The main daemon's unit hardening stays in force.

The API answers at `https://sandboxes.example.com`, with a certificate that renews itself. Omit
`HERMITBOX_DOMAIN` to install a local server with loopback port 7331 and path aliases. Once a
server has a domain, the installer refuses a different one until its public addresses are migrated.

See [Host on a server with root](https://docs.hermitbox.dev/v0.3.2/hosting/server.md) for the full setup, and
[operations](https://docs.hermitbox.dev/v0.3.2/guides/operate.md) for DNS, TLS, server upgrades and explicit data removal.

## Inside a container

```sh
curl -fsSL https://hbx.sh | sh
```

An ordinary account still gets the user preset. Root in a container gets the container preset,
with managed files under:

- `/opt/hermitbox`
- `/etc/hermitbox-local`
- `/var/lib/hermitbox`
- `/run/hermitbox-local`

Embedded PostgreSQL drops to its dedicated nonzero UID.

Without systemd in the container, the command doesn't return: once installed, Hermitbox keeps
running in the foreground as the container's supervisor, and its summary says so. Run it as the
container's command, or start it in the background and use `hermitbox` from another shell:

```sh
(curl -fsSL https://hbx.sh | sh > ~/hermitbox-install.log 2>&1 &)
```

Process confinement must actually pass. If the kernel lacks a syscall it needs, Hermitbox refuses
and says what to change. A mounted Docker socket alone does not establish correct host bind paths
or firewall coverage, so for image workloads use the server preset on the engine host.

## Platform that runs images

```sh
docker run -p 8080:8080 -v hermitbox:/var/lib/hermitbox ghcr.io/hermitbox/hermitbox:0.3.2
```

The release image runs the same supervisor. The first key appears once in its log. Keep the named
volume, and put a trusted TLS terminator in front for remote access.

See [Deploy the release image](https://docs.hermitbox.dev/v0.3.2/hosting/container.md) for Render, external stores and image
tiers, and [Hosting](https://docs.hermitbox.dev/v0.3.2/hosting.md) for each platform.

## Node joining a fleet

A fleet is several machines running Hermitbox together. Each new machine joins as a node with a
token from the fleet:

```sh
export HERMITBOX_JOIN_TOKEN='<fleet-token>'

curl -fsSL https://hbx.sh | \
  sudo --preserve-env=HERMITBOX_JOIN_TOKEN HERMITBOX_PRESET=node sh
```

The token stays in the environment, which only the account that set it and root can read. A token
in a command's arguments is visible to every account on the host while the command runs.

The node preset uses the existing root and systemd fleet join. It installs the verifier and uses
the supplied fleet token. Before joining, it verifies the signed daemon and agent bootstrap
independently of the fleet. The token is an operator credential: keep it out of shell history and
CI output.

On first enrollment the node denies all container images by default. To allow selected images, add
`HERMITBOX_NODE_ALLOW_IMAGES='alpine:,registry.example/team/'` beside `HERMITBOX_PRESET=node` in
the command above. Separate entries with commas. Each means the same as one
`hermitbox node join --allow-image` value:

- A repository ending in `:` permits its tags.
- A namespace ending in `/` permits images under it.
- A complete SHA-256 image reference permits that digest alone.

Repeat enrollment keeps the node's saved policy. See [operations](https://docs.hermitbox.dev/v0.3.2/guides/operate.md) for issuing
a token and node policy, [Nodes and fleet](https://docs.hermitbox.dev/v0.3.2/concepts/fleet.md) for how nodes and control work
together, and [Add machines](https://docs.hermitbox.dev/v0.3.2/guides/add-machines.md) for machine providers.

## Install options

Set `HERMITBOX_NO_UP=1` on the installer process to install only the CLI. Preview builds are signed
with a separate ML-DSA-65 identity and cannot replace production release keys.

Local installations use every supported tier by default. To serve one backend, set
`HERMITBOX_RUNTIME` to `container`, `process` or `wasm` when installing. Restarts and upgrades use
the saved runtime, and each workload keeps its chosen tier.

The container tier needs a supported engine running on the same host, so an installation inside a
container keeps that tier off. `hermitbox doctor` and `hermitboxd doctor` report which tiers are
available.
