Use Rex with a cloud Linux VM
Run a persistent Rex server on an arvm Ubuntu 24.04 VM so your shells, editors, and test runs survive closing your laptop and stay reachable from any Rex client.
1. Create a VM and install SSH config
Create a default machine (4 vCPUs, 8 GB RAM, 51 GB disk) with a longer idle timeout so a short break does not stop your server, then write the SSH config entry so plain ssh and rex can reach it by name.
$ arvm new --idle-timeout 4h
$ arvm ssh-config --install
The examples below use the machine name calm-river-otter. Replace it with the name arvm new prints. For overnight runs with no open SSH connection, pass --idle-timeout never instead of 4h.
2. Install the Rex server over SSH
Because arvm machines run Ubuntu 24.04 with systemd, rex server install installs rex into ~/.local/bin on the VM, enables the rex.socket systemd user unit with lingering, connects over SSH, and registers the host under the label you choose.
$ rex server install ssh://calm-river-otter --label devbox
Verify that your local Rex CLI can reach the remote host:
$ rex hosts check --json
The devbox entry reports reachable once the systemd user unit answers over SSH.
3. Run persistent sessions on the VM
Prefix any rex command with -S devbox to manage sessions, tabs, and panes on the cloud machine. Processes started inside those sessions keep running if your laptop sleeps or changes networks.
$ rex -S devbox new app --window Shell
$ rex -S devbox ls --json
$ rex -S devbox run -s app --label Tests --keep-open -- uname -a
Inspect a pane’s scrollback from any connected device after reconnecting:
$ rex -S devbox capture -s app -b BLOCK_ID --trim
Replace BLOCK_ID with the .block_ids[0] value returned by rex -S devbox run --json, or find it with rex -S devbox block ls -s app --json.
4. Stop the VM when you finish
When your work for the day is done, push your Git branches and stop the machine:
$ arvm stop calm-river-otter
A stopped machine costs $0 and keeps its 51 GB disk, its installed Rex server, and its SSH name. Run arvm start calm-river-otter before reconnecting the next day.
Idle stop and billing
A running default machine costs $0.018 an hour, so a full month of it running 24/7 uses $13.14 of the $20 monthly plan. Stopping a machine stops billing immediately.
An open SSH connection through the gateway keeps the machine awake. Once you close your laptop and the SSH connection drops, the idle timer counts down whenever CPU utilization stays below the idle threshold. Set --idle-timeout 4h for daytime breaks or --idle-timeout never for overnight jobs, and stop the machine when you do not need it. See Idle stop and Billing.
Machine disks are stored on a single drive with no automatic backups. Keep source code in Git.
Troubleshooting
| Symptom | What to do |
|---|---|
rex hosts check reports devbox unreachable |
Check arvm get calm-river-otter. Plain SSH does not wake a stopped machine; run arvm start calm-river-otter and retry. |
rex server install cannot resolve calm-river-otter |
Run arvm ssh-config --install so ~/.ssh/config includes arvm’s Host blocks, then verify ssh calm-river-otter uname -r. |
| Session disappeared after your laptop slept | The machine hit its idle timeout while CPU was quiet. Check arvm events calm-river-otter for idle_timeout, then create or update the machine with a longer timeout. |
SSH prints REMOTE HOST IDENTIFICATION HAS CHANGED |
Re-run arvm ssh-config --install to refresh arvm’s gateway known_hosts file. |