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

# Rex

> Add an instabox machine as a remote host in Rex, so its sessions and agents run there.

[Rex](https://superlogical.com/rex) runs coding agents in sessions. Add a machine as a remote host
in Rex, and its sessions and agents run there.

You need the [Rex app](https://superlogical.com/rex) on a Mac with Apple silicon and macOS 15 or
later, and the [instabox CLI](https://instabox.sh/docs/quickstart.md).

**1. Create a machine and set up Rex on it**

```bash theme={null}
instabox create --name cloud-dev
```

In the dashboard, open `cloud-dev`, then **Integrations**, and select **Rex**. Select
**Create SSH token**, then **Set up Rex**, which installs Rex and its server on the machine.

**2. Trust the host key**

Rex cannot ask whether to trust a new host key, so connect once from a terminal.

```bash theme={null}
ssh -o StrictHostKeyChecking=accept-new -p 2222 ibssh_…@ssh.instabox.sh exit
```

**3. Add the host**

In Rex, open **Settings**, select **Remote Hosts**, then **Add Remote Host…**. Paste the SSH URI
from the dialog as the **URL**, in the form `ssh://ibssh_…@ssh.instabox.sh:2222`. Enter
`cloud-dev` as the **Name**, because Rex otherwise names the host after the URI's login, which
is the token. Then select **Add**.

**4. Open a session**

In Rex's window, click the session name at the top left, or press **⌘K**. Select the
new-session button at the right of the `cloud-dev` row. Rex opens a shell on the machine, in its
home directory.

> [!WARNING]
>
> The URI holds an SSH token: anyone with it gets a shell. Rex saves it on your Mac and shows it
> under **Settings → Remote Hosts**. Revoke it under **Details → SSH**.

> [!NOTE]
>
> The dashboard makes a background SSH token for Rex: leaving Rex open does not keep the machine
> awake, and connecting does not wake a paused machine. Resume it from the dashboard or with
> `instabox resume cloud-dev` first. See
> [what wakes a machine](https://instabox.sh/docs/machines/auto-pause.md#what-wakes-a-machine).

> [accordion] Check Rex on the machine
>
> ```bash theme={null}
> instabox exec cloud-dev -- systemctl --user is-active rex.socket
> ```
>
> If it does not print `active`, select **Set up again** in the dialog.

> [card] [SSH](https://instabox.sh/docs/access/ssh.md)
>
> Tokens, expiry, and revoking access.

> [card] [Auto-pause and max-run](https://instabox.sh/docs/machines/auto-pause.md)
>
> What counts as idle and what wakes a machine.
