Skip to content
arvm
Docs menu

Use OpenCode and OpenCode Desktop over SSH

Run OpenCode on an arvm Ubuntu 24.04 VM so coding sessions, builds, and Docker containers run in the cloud while you drive them from the terminal, OpenCode Desktop, or a browser.

1. Create a VM and install SSH config

Create a default machine (4 vCPUs, 8 GB RAM, 51 GB disk) with a 4-hour idle timeout and install its SSH config entry so plain ssh reaches it by name.

Terminal
$ arvm new --idle-timeout 4h
$ arvm ssh-config --install

The examples below use calm-river-otter. Replace it with the name arvm new prints.

2. Install OpenCode on the VM

Open a shell on the VM and install OpenCode:

Terminal
$ arvm ssh calm-river-otter
Terminal
dev@calm-river-otter:~$ curl -fsSL https://opencode.ai/install | bash
dev@calm-river-otter:~$ opencode --version

Sign in to your model provider with opencode auth login, then clone your repository inside /home/dev. To use the terminal UI directly inside the VM, run opencode inside tmux or Rex.

3. Connect from OpenCode Desktop or a browser

Start the OpenCode server inside the VM, then choose either a local SSH tunnel or a private HTTPS URL.

Option A: SSH port forwarding (local-only port)

Bind opencode serve to 127.0.0.1 inside the VM so nothing listens on the public IPv6 address:

Terminal
dev@calm-river-otter:~$ opencode serve --hostname 127.0.0.1 --port 4096

From your laptop, forward port 4096 over SSH:

Terminal
$ arvm forward calm-river-otter 4096

Point OpenCode Desktop (or opencode --server http://127.0.0.1:4096) at http://127.0.0.1:4096.

Option B: Private HTTPS URL through the gateway

If you want to connect from another device without keeping an SSH tunnel open, close direct IPv6 inbound traffic first so port 4096 is reachable only through arvm’s signed HTTPS gateway:

Terminal
$ arvm inbound calm-river-otter closed

Inside the VM, start the server on all interfaces so the gateway can reach it:

Terminal
dev@calm-river-otter:~$ opencode serve --hostname 0.0.0.0 --port 4096

Expose port 4096 on a private HTTPS URL:

Terminal
$ arvm expose calm-river-otter 4096

Open the printed signed_url in a browser or paste the endpoint into your client. Remove the URL when done with arvm unexpose calm-river-otter 4096.

4. Stop the VM when you finish

Push your branches to Git and stop the machine:

Terminal
$ arvm stop calm-river-otter

A stopped machine costs $0 and keeps OpenCode, your provider configuration, and your repositories on its 51 GB disk.

Idle stop and billing

A running default machine costs $0.018 an hour out of your $20 monthly plan, so a full month uses $13.14 of the $20. Stopped machines cost $0.

Open SSH tunnels (arvm forward) and HTTP requests to an exposed endpoint both count as gateway activity and reset the idle timer. After you close your tunnel and stop sending requests, idle stop shuts the machine down once the timeout passes. See Idle stop and Public URLs.

Machine disks live on one drive with no automatic backups. Keep your work pushed to Git.

Troubleshooting

Symptom What to do
arvm expose URL returns 502 or cannot reach OpenCode opencode serve bound to 127.0.0.1 is unreachable from the gateway. Close direct IPv6 with arvm inbound calm-river-otter closed and start with --hostname 0.0.0.0 --port 4096.
arvm expose URL returns 401 Endpoints are private by default. Open the signed_url from arvm endpoints calm-river-otter once to set the session cookie.
arvm forward stops answering after laptop sleep Re-run arvm forward calm-river-otter 4096. If the VM stopped while you were away, run arvm start calm-river-otter first.
opencode is not found in a non-interactive SSH command The installer places binaries under ~/.opencode/bin or ~/.local/bin. Add that directory to ~/.profile or call the full binary path.