---
title: "Run a Rex server on a remote Linux VM"
description: "Run the Rex server (beta) on an always-on exe.dev VM and add it to Rex for Mac over Tailscale: sessions and agents keep running when your Mac sleeps."
url: https://exe.dev/deploy/rex
category: "AI agents"
updated: 2026-10-31
---

# Run a Rex server on a remote Linux VM

An always-on remote host for Rex, with agents ready and no API keys.

- **Software:** Rex (https://www.superlogical.com/rex)
- **License:** Proprietary (free beta)
- **Time:** 10 minutes
- **Example VM name:** `my-rex` (yours will differ; on the VM, `hostname` prints it)
- **Machine-readable:** https://exe.dev/deploy/rex/manifest.json

## What you get

- Rex's Linux server from the preview channel, running as `exedev` and back after a reboot
- The server on your tailnet as `my-rex` once you open its Tailscale sign-in link
- Claude Code and Codex using exe.dev's LLM integration, with Rex's agent skill installed
- A Rex session `work` in `~/project` where Claude Code answers `OK`

Running on the VM:

- **Rex server**: the rex package (0.1.0 preview), run as your account by a systemd service, data in `~/.local/state/rex`
- **Tailscale, built into Rex**: the server joins your tailnet as its own device; no tailscaled needed, data in `~/.local/state/rex/tsnet`
- **Claude Code and Codex**: preinstalled; connected to exe.dev's LLM integration, with Rex's agent skill, data in `~/.claude, ~/.codex`
- **Your project**, data in `~/project`

How it is reached:

- https://my-rex.<your-tailnet>.ts.net (private): the Rex server, for Rex for Mac; only your Tailscale account gets in
- ssh my-rex.exe.xyz (private): your terminal, and an SSH tunnel to Rex if you don't use Tailscale

## Deploy with Shelley

Open https://exe.dev/new?prompt=Set%20up%20Rex%20on%20this%20VM%20by%20following%20the%20exe.dev%20recipe%20at%20https%3A%2F%2Fexe.dev%2Fdeploy%2Frex.md%20from%20top%20to%20bottom.%0A%0AThe%20recipe%27s%20example%20VM%20name%20is%20my-rex.%20This%20VM%27s%20name%20is%20the%20output%20of%20%60hostname%60%3A%20use%20it%20wherever%20the%20recipe%20writes%20my-rex.%20Skip%20the%20step%20that%20creates%20the%20VM%3B%20you%20are%20on%20it.%0A%0AYou%20are%20done%20when%20all%20of%20these%20are%20true.%20Check%20each%20one%20yourself%3A%0A-%20Rex%27s%20Linux%20server%20from%20the%20preview%20channel%2C%20running%20as%20%60exedev%60%20and%20back%20after%20a%20reboot%0A-%20The%20server%20on%20your%20tailnet%20as%20%60my-rex%60%20once%20you%20open%20its%20Tailscale%20sign-in%20link%0A-%20Claude%20Code%20and%20Codex%20using%20exe.dev%27s%20LLM%20integration%2C%20with%20Rex%27s%20agent%20skill%20installed%0A-%20A%20Rex%20session%20%60work%60%20in%20%60~%2Fproject%60%20where%20Claude%20Code%20answers%20%60OK%60%0A%0ARun%20the%20VM-side%20commands%20in%20%22Set%20up%20the%20VM%22%20only%3B%20skip%20creating%20the%20VM.%0AIf%20%60exeuntu%20configure%60%20reports%20an%20existing%20user%20config%2C%20leave%20it%20alone.%0AIf%20%60~%2Fproject%60%20already%20exists%2C%20leave%20it%20alone.%20Don%27t%20start%20interactive%0Aagents.%20Verify%20with%20the%20checks%20at%20the%20end%20of%20that%20section%3A%20the%20service%0Ais%20active%2C%20%60rex%20version%60%20starts%20with%20%60rex%200.1.0%60%2C%20and%20the%20%60work%60%20session%0Ashows%20%60OK%60%20from%20Claude%20Code.%20Skip%20the%20later%20sections%20and%20the%20FAQ.%0AFinish%20by%20giving%20the%20owner%20the%20Tailscale%20sign-in%20link%20from%0A%60rex%20server%20status%60%20%28the%20%60authenticate%3A%60%20line%29%2C%20and%20tell%20them%20to%20open%20it%0Asigned%20in%20to%20the%20tailnet%20their%20Mac%20is%20on%2C%20check%20that%20MagicDNS%20and%20HTTPS%0Acertificates%20are%20on%20for%20that%20tailnet%2C%20then%20add%0A%60https%3A%2F%2F%3Cthis%20VM%27s%20name%3E.%3Ctailnet%3E.ts.net%60%20in%20Rex%20for%20Mac%20with%0A%2A%2AAdd%20Remote%20Host%E2%80%A6%2A%2A%20%28%22Add%20it%20to%20Rex%20for%20Mac%22%29.%20Never%20put%20Rex%20behind%0Aexe.dev%27s%20HTTPS%20proxy%20or%20use%20%60--allow-anonymous%60.%0A%0AFinish%20with%20the%20URLs%20I%20should%20open.%0A to create a VM whose agent, Shelley, follows this recipe. From a terminal:

```sh
curl -fsSL https://exe.dev/deploy/rex/prompt.txt | ssh exe.dev new --prompt=/dev/stdin
```

Or follow the steps below by hand.

[Rex](https://www.superlogical.com/rex) is a terminal and terminal
multiplexer from Superlogical, Mitchell Hashimoto's new company. Your
sessions live in a Rex server, not in the window: Rex for Mac runs one
locally and can attach to others as remote hosts. Put a server on an
exe.dev VM and the shells and coding agents in it keep working when your
Mac sleeps or travels. The VM is always on, its disk is persistent, and
you reattach from Rex for Mac where you left off.

The VM comes with Claude Code and Codex, which use exe.dev's
[LLM integration](/docs/integrations-llm): no API keys on the VM, and
model usage billed to your exe.dev account.

> [!WARNING]
> Rex is in beta. You need a Rex for Mac tester build (from Superlogical's
> mailing list) to use this server from a Mac, and the Linux server is
> labeled alpha. Rex has no logins of its own yet: the server trusts
> Tailscale to say who is connecting, which is why this guide uses
> Tailscale and never the HTTPS proxy.

## Set up the VM

On your computer, create a VM and connect to it. Pick any free name; if
you've already clicked Deploy or have a VM, skip the first command and use
its name:

```bash
ssh exe.dev new --name=my-rex
ssh my-rex.exe.xyz
```

On the VM, connect Claude Code and Codex to the LLM integration, then
install Rex with Superlogical's install script. It adds Rex's apt
repository, so updates come with `apt`. There's no stable release yet, so
ask for the preview channel, the tagged builds:

```bash
exeuntu configure claude
exeuntu configure codex
curl -fsSL https://pkgs.superlogical.com/rex/install.sh | sh -s -- --channel preview
rex version
```

The package brings services for a shared server and a login server; leave
them off. Instead, run a personal server as `exedev`, the account with your
files and agents, and let it join your tailnet as `my-rex` with the
Tailscale built into Rex. The second file stops Ubuntu's `needrestart`
from restarting it during package upgrades, which would stop every program
running in Rex:

```bash
sudo tee /etc/systemd/system/rex-personal.service >/dev/null <<EOF
[Unit]
Description=Rex server for $USER, on the tailnet as $(hostname)
Wants=network-online.target
After=network-online.target user@$(id -u).service

[Service]
Type=notify
NotifyAccess=main
User=$USER
Environment=XDG_RUNTIME_DIR=/run/user/$(id -u)
Environment=GODEBUG=
ExecStart=/usr/bin/rex server run --log-format text --tailscale --tailscale-hostname $(hostname)
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF
echo '$nrconf{override_rc}{qr(^rex-personal\.service$)} = 0;' | sudo tee /etc/needrestart/conf.d/rex-personal.conf
sudo systemctl daemon-reload
sudo systemctl enable --now rex-personal.service
```

Install Rex's skill and hooks for the agents, so they can open tabs, split
panes and read other terminals, and make a project, a Git repository so
you can review and undo what the agents change. Then open a session there:

```bash
rex skill setup
git init ~/project
rex new work -c ~/project
```

Check it. The service is active, the server is the preview build, and
Claude Code, typed into the `work` session, answers `OK` on its screen:

```bash
systemctl is-active rex-personal
rex server status | grep -E '^(version|tailscale)'
rex send -s work 'claude -p --model haiku "Reply with exactly: OK"'
rex send-key -s work Enter
sleep 20; rex capture -s work | tail -3
```

`tailscale: needs login` is expected until the next step.

## Sign in to Tailscale

Rex for Mac reaches the server over your tailnet. You need a
[Tailscale](https://tailscale.com) account, with the Tailscale app on your
Mac, and two settings on in the
[admin console](https://login.tailscale.com/admin/dns): **MagicDNS** and
**HTTPS Certificates**.

On the VM, print the server's sign-in link:

```bash
rex server status
```

Open the `authenticate:` link in a browser where you're signed in to
Tailscale, and approve the device. It joins your tailnet as **my-rex**,
owned by you, and from then on the server signs itself in after restarts.
Run `rex server status` again: the `tailscale:` line no longer says
`needs login`.

Only devices signed in as you get in; the server asks Tailscale who each
caller is. To let other people in, see Rex's
[Who Can Connect](https://www.superlogical.com/rex/docs/linux/remote-access#who-can-connect).
The server's sign-in counts as a device on your tailnet, and Tailscale
expires device keys after 180 days unless you
[turn off key expiry](https://tailscale.com/kb/1028/key-expiry) for
**my-rex**.

## Add it to Rex for Mac

In Rex for Mac, choose **Add Remote Host…** and enter the server's
address, with your tailnet's name:

```
https://my-rex.<your-tailnet>.ts.net
```

The `work` session from setup is there. Open it, or start a new one, and
run an agent in `~/project`:

```bash
cd ~/project && claude
```

The first run asks for a theme and whether you trust the folder. Then give
it a task, such as:

> Write index.html: a one-page site for a very opinionated cat. Keep it short.

Close the laptop; the agent carries on, and the session is as you left it
when you reattach. Codex works the same way (`codex`); the first time,
approve Rex's hook with `/hooks` so Codex knows it runs in Rex.

The `rex` command works from a terminal on your Mac too, and inside Rex
terminals there:

```bash
rex hosts add my-rex https://my-rex.<your-tailnet>.ts.net
rex -S my-rex ls
```

## Let agents drive Rex

`rex skill setup` taught Claude Code and Codex the `rex` commands. Ask an
agent running in Rex to "start the dev server in another tab and tell me
when it's ready" or "run the tests beside you and fix whatever fails", and
you watch it happen in the window. Rex lists more in its
[agent docs](https://www.superlogical.com/rex/docs/automate/agent-skill).
Run `rex skill setup` again after installing another agent.

Shelley, exe.dev's own agent at `https://my-rex.shelley.exe.xyz/`, picks
up the same skill: ask it to open a session in Rex and run something, and
it shows up in Rex for Mac.

To preview what an agent builds, have it serve on `0.0.0.0:8000` and open
`https://my-rex.exe.xyz/`, private until you [share it](/docs/sharing).

## No Tailscale? Use an SSH tunnel

The server's own socket on the VM is `/run/user/1000/rex/server.sock`, and
Rex trusts whoever connects there as `exedev`. SSH can carry that socket to
your computer, protected by your exe.dev SSH key. On your Mac, keep this
running:

```bash
ssh -N -L /tmp/rex-my-rex.sock:/run/user/1000/rex/server.sock my-rex.exe.xyz
```

Then, in another terminal:

```bash
rex -S unix:///tmp/rex-my-rex.sock ls
```

We tested this with the `rex` command. We couldn't test whether Rex for
Mac's **Add Remote Host…** takes a socket address; Rex's docs only
describe Tailscale for the app. The tunnel ends when SSH does, and the
socket file stays behind: delete `/tmp/rex-my-rex.sock` before you open it
again.

## What keeps running

- **Mac asleep, Rex closed, Wi-Fi gone:** everything on the VM keeps
  running.
- **The VM restarts:** the server comes back on its own with the same
  sessions, tabs and panes, each a fresh shell in the same folder.
  Programs that were running in them have stopped.
- **Rex updates:** `apt` installs the new version but leaves the running
  server alone. It switches when you restart it (see [Update](#update)).

## Back up and restore

Commit and push your code; that's the copy that matters most. For a copy
of the whole VM, run this on your computer (choose a free backup name):

```bash
ssh exe.dev cp my-rex my-rex-backup
```

The copy has the original's Tailscale identity too, so don't keep both
running. To use the copy beside the original, give it its own on the copy,
then open the new link from `rex server status`:

```bash
sudo systemctl stop rex-personal
rm -rf ~/.local/state/rex/tsnet
sudo sed -i "s/--tailscale-hostname .*/--tailscale-hostname $(hostname)/" /etc/systemd/system/rex-personal.service
sudo systemctl daemon-reload && sudo systemctl start rex-personal
```

## Update

On the VM:

```bash
sudo apt-get update && sudo apt-get install --only-upgrade rex
rex version | head -1
rex server status | grep '^version'
```

If the two versions differ, the server is still on the old one. When
nothing important is running in Rex, restart it; sessions come back as in
a reboot:

```bash
sudo systemctl restart rex-personal
```

Rex for Mac and the server don't need the same version; if they drift too
far apart, the connection error says which one to update. Update the agents
with `sudo exeuntu update claude` and `sudo exeuntu update codex`.

## Troubleshooting

- **Rex for Mac can't reach the server.** On the VM, `rex server status`
  should show Tailscale signed in. Check that your Mac's Tailscale app is
  connected to the same tailnet, that MagicDNS and HTTPS certificates are
  on, and that the device is named `my-rex` in the admin console (Tailscale
  adds a number if the name was taken).
- **Rex for Mac is refused.** Only Tailscale devices signed in as the
  server's owner get in. `rex client ls` on the VM shows who is connected.
- **`rex` says `(R)?ex`.** Ubuntu has an unrelated Perl tool called rex;
  run the install script again, and see `apt-cache policy rex`.
- **The server won't start.** `journalctl -u rex-personal -e` shows why.
  `rex server status` prints the path of the server's own log.
- **An agent doesn't answer.** On the VM, `claude -p "Reply with exactly:
  OK"` shows whether Claude Code works on its own; rerun
  `exeuntu configure claude` if not, then `rex skill setup`.

For everything else, see Rex's
[Linux server docs](https://www.superlogical.com/rex/docs/linux/server-modes)
and [Remote Access](https://www.superlogical.com/rex/docs/linux/remote-access).

## Frequently asked questions

### Can I use Rex yet?

Rex is in public testing. Rex for Mac goes to people on Superlogical's [mailing list](https://www.superlogical.com/rex), in waves; the Linux server is labeled alpha, and its packages install without an account. Clients for iOS, Linux and Windows aren't part of testing yet. Expect commands and options to change between builds.

### Can I reach Rex through exe.dev's HTTPS proxy instead of Tailscale?

No. Rex has no logins of its own yet, so on a plain HTTP listener it needs `--allow-anonymous`, and then every connection can run programs as you. Rex for Mac can't sign in to exe.dev's proxy, and a share link or `share set-public` would hand out a shell. Use Tailscale, or the [SSH tunnel](#no-tailscale-use-an-ssh-tunnel), which uses your exe.dev SSH key.

### Why a personal server, not the shared or login server?

The personal server runs as `exedev`, the account that has your files, Git setup and agent configs, and only you use it. The shared server runs everything as a separate `rex` account and loses its sessions on every upgrade. For several people, each as their own Linux account, Rex's [login server](https://www.superlogical.com/rex/docs/linux/login-server) with Tailscale Serve is the way.

### Can I use my own Claude or ChatGPT subscription?

Yes. On the VM, run `claude auth login` or `codex login` after removing what `exeuntu configure` added: `apiKeyHelper` and `env.ANTHROPIC_BASE_URL` in `~/.claude/settings.json`, and the `exe-llm` provider in `~/.codex/config.toml`. Keep the `hooks` entries Rex added.

### How much does it cost?

Superlogical says Rex is and will stay free, with no account needed for the client or server. You pay for the VM as part of your exe.dev plan, and model usage through the [LLM integration](/docs/integrations-llm) is billed to your exe.dev account. A free Tailscale plan is enough.

### Does Rex send data anywhere?

Rex [collects no telemetry](https://www.superlogical.com/rex/docs/reference/privacy). The server talks to Superlogical's package repository when apt updates, and to Tailscale's coordination servers because you turned Tailscale on. Programs you run in Rex make their own connections.


## Related

- [Run Herdr agents on a remote machine](https://exe.dev/deploy/herdr.md): An always-on SSH machine for Herdr, with agents ready and no API keys.
- [Run Orca's agents on a remote server](https://exe.dev/deploy/orca.md): A big, always-on box for Orca's parallel coding agents.
- [Run Claude Code on a remote server](https://exe.dev/deploy/claude-code.md): A computer for Claude. A breather for your laptop.
- [Run Codex on a remote server](https://exe.dev/deploy/codex.md): A computer for Codex. An early night for your laptop.
- [Run T3 Code on a remote server](https://exe.dev/deploy/t3code.md): Your coding agents on an always-on VM, steered from your phone.
- [Host OpenClaw](https://exe.dev/deploy/openclaw.md): An AI sidekick with its own computer. Your laptop can take a nap.
