Remote machines
Manage coding-agent sessions running on several machines from one ocman dashboard. One ocman acts as the hub. It attaches to other ocman instances (the remotes) over a long-lived gRPC connection and shows every machine’s sessions in a single list. You can open, watch live, and drive any remote session, sending prompts, answering permission and question prompts, aborting and compacting, exactly as if it were local. Creating a session is machine-aware: the hub picks the host where the project already lives, and asks you to choose when it lives on more than one.
Off by default. A plain
./ocmanwith no remotes behaves exactly as before, and nothing below is required for single-machine use.
How it works
Every ocman has a stable random instance ID and a remote-access token,
generated on first run and stored in state.db. A remote opts in to being
managed by starting its gRPC server with -remote-listen. The hub dials each
remote, authenticates with that remote’s token, and registers its sessions
under a host badge.
The browser only ever talks to the hub over the normal REST/SSE API, and the hub fans out to remotes over gRPC. Host-local work (tmux, git worktrees, the in-app terminal, the agent process) always runs on the machine that owns it, so the hub never reaches into a remote’s filesystem directly. Opening the terminal on a remote project’s session opens a shell on the remote machine: the hub tunnels the browser WebSocket to the owner over a bidirectional gRPC stream, so keystrokes and PTY output cross the wire while the shell, cwd and tmux windows all stay on the remote.
A remote advertises the platforms it runs (-platforms). One started with
claudecode shows its Claude Code sessions on the hub too: listing, turns,
permission prompts and new sessions all run on the remote, under the remote’s
own claude login. The hub needs no Claude install for this. A remote that
runs several platforms appears once per platform (r-<id>:opencode,
r-<id>:claudecode, r-<id>:codex when enabled); an older remote that does not advertise its platforms
is treated as OpenCode-only. Things tied to the Claude install are per
machine: the terminal-session hooks are installed from the remote machine’s
own ocman Settings, and Provider usage on the hub lists only the hub’s
own Claude account. Codex likewise runs with the remote’s own installation,
CODEX_HOME and login; enabling it only on the hub does not enable it remotely.
See Claude Code
and Codex
.
Clone a project onto another machine
In a new conversation, the machine picker also lists connected machines with
no matching project. Select one to review the repository URL and destination.
Ocman suggests ~/src/<host>/<repository> on that machine. HTTPS and SSH URLs
are supported; embedded HTTPS credentials are removed. The destination must not
already exist, even if it is empty.
Confirming only saves the choice in the conversation draft. The first prompt clones the repository on the selected machine, then starts the session in that checkout. Clone progress and errors appear below the prompt. Reloading keeps the choice, and a failed clone leaves the prompt available for an explicit retry. If cloning succeeds but launching fails, retry reuses that completed clone.
The destination machine needs Git, repository access, and its own credentials. Local uncommitted changes and unpushed commits do not transfer. Nothing is copied from the source checkout. Older remotes without clone support report an error without creating a session.
sequenceDiagram
participant Browser
participant Hub
participant Owner as Selected machine
Browser->>Hub: Plan clone URL and destination
Hub->>Owner: Host.PlanProjectClone over gRPC
Owner-->>Hub: Validated URL and absolute destination
Hub-->>Browser: Clone plan
Note over Browser: Confirm and save in shared draft storage
Browser->>Hub: First prompt with clone consent
Hub->>Owner: Host.CloneProject over gRPC
Owner->>Owner: Clone using owner-local Git credentials
Hub->>Owner: Start session and deliver prompt
Prerequisites
- ocman running on each machine you want to manage. The same version is safest; a protocol-version handshake flags incompatible builds.
- Network reachability from the hub to each remote’s gRPC port. ocman does not manage networking, so use direct reachability, a VPN, or a trusted overlay such as Tailscale or WireGuard.
- TLS certificates, unless both machines sit on a trusted overlay.
Step-by-step setup
1. On each remote machine, turn on remote access
Start ocman with -remote-listen set to the address its gRPC server
should bind. Use a routable address (not 127.0.0.1) so the hub can
reach it across the network:
# On the workstation you want to manage remotely:
ocman -remote-listen 0.0.0.0:8230 \
-remote-tls-cert cert.pem -remote-tls-key key.pemThis starts the gRPC server in addition to the normal web UI on :8228. The
remote’s existing REST behaviour and localhost posture are unchanged.
Pick any free port for the gRPC server;
8230is just a convention. The web UI port (-addr, default:8228) is independent.
2. On each remote machine, copy its access token
Open the remote’s own dashboard and go to Settings → Remotes. The This machine entry shows the remote’s instance ID and listen address. Click Reveal token and copy the value.
You can also fetch it over the API on that machine:
curl -s -X POST http://localhost:8228/api/settings/remote-access/reveal-token
# -> { "token": "…" }The token authenticates inbound gRPC connections. It is independent of
the web UI password (OCMAN_AUTH_PASSWORD).
3. On the hub, attach the remote
Open the hub’s dashboard, go to Settings → Remotes → Attach a remote, and enter:
- Address. Use
grpcs://workstation.lan:8230to dial TLS. Plaintext requires an explicitgrpc://address and-remote-trusted-overlayon the remote; use it only over Tailscale, WireGuard, or an equivalent private encrypted overlay. - Token. The value you revealed in step 2.
- Display name (optional). A friendly label for the host badge.
Click Add remote. The hub dials, runs the handshake, and the row flips to connected. The remote’s sessions now appear in the unified list with its host badge.
4. Use it
Unified list. Local and remote sessions are interleaved, each tagged with the owning machine. A slow or offline remote never blocks the list; its last-known sessions show dimmed with an offline marker.
Open and drive. Click any remote session to stream its transcript and use the composer, permission replies, abort and compact. These route to the owning remote and run there.
New session. A new conversation started from the project picker targets the project’s own machine (this machine for local projects), but nothing is created until the first prompt. Use the composer’s machine selector before that prompt to start it on another machine that has the project instead.
PRs and issues. The sidebar uses the hub’s synced checkout and linked-PR data. The hub fetches PRs, issues, and checks with its own forge credentials. Branch highlighting uses the session’s reported branch. Opening or refreshing the sidebar does not ask the remote to inspect Git or contact the forge. Upgrade both instances for synced sidebar data. Repository work still runs on the owner.
Session PR watches. Linked PRs, polling checkpoints and pending updates live on the session’s owning machine. Linking, watching, stopping a watch, checks and feedback drafts behave the same through the hub or directly on that machine. The owner polls with its own forge credentials and delivers updates through its session queue, even while the hub is disconnected. Older hub-stored links transfer automatically when the owner is reachable; failed transfers retain the original state and never poll on the wrong host. Upgrade both instances to use owner-routed watches. Owner-side watch changes, including automatic stops, reach the hub through
StreamSessionChangesand then browser SSE. The connection supervisor owns and joins the stream, retries transient stream failures and reconciles known session rows on attachment. Older owners without this RPC retain polling.Background tasks. The task page and active counter include application work on this machine and connected remotes, with machine badges on each row. Progress and history stay on the machine doing the work; the hub reads them over authenticated gRPC. The task API accepts
remoteIdto scope list, count and detail reads; an explicit disconnected owner returns unavailable, never another machine’s tasks. Unscoped list and count reads omit remotes whose task service is unavailable, so an older or failing remote cannot block work from the other machines. Remote task support requires an updated remote.Worktrees. The project Worktrees page (
/project/<dir>/worktrees) belongs to one machine, named by?remoteId=<id>; without it the page is this machine’s. Listing, creating, deleting, session counts and Open session stay on that machine even when another has the same path. When that remote is not connected, the page shows as unavailable instead of falling back to this machine. It becomes available when the remote reconnects, without a reload.Relaunch. When a send finds a session’s OpenCode instance gone, the instance is relaunched on the machine that owns the session, never on another machine that happens to have the same directory.
flowchart LR
Browser -->|Sidebar reads| Hub
Owner -->|Checkout and link snapshots| Hub
Hub -->|PR metadata and CI| Forge
Hub -->|Launches and watch changes| Owner
Owner -->|Background watch polling| Forge
New conversations appear alongside sessions in the sidebar immediately, at the
top of their project in grouped view. You can prepare several, switch between
them, and discard one with its archive-style button, a middle-click on its
sidebar row, or /archive in its composer.
Their text, machine, target, model and agent selections are saved separately in
this browser and survive a reload. Preparing a draft does not start an agent or
create a worktree. Sending its first prompt creates the real session and removes
that draft from the list, even if you have switched to another draft while
it starts. Reopening a pending draft shows its submitted prompt and keeps the
composer and machine/target controls locked until that start finishes. Two tabs
opening the same draft share one start and its completion, including after a
reload. Reload never replays a first submission. A pending claim left by an
interrupted tab stays locked. Request errors allow an explicit retry, which can
create another session if the server accepted the first request but its response
was lost. Discarding a draft in another tab
replaces its open composer with a fresh, empty draft identity.
The created session also holds follow-ups while its first file upload, command, or shell submission is running, including in another tab. If the originating tab closes or reloads during that delivery, the session reports an unknown outcome. You can explicitly release its first-delivery lock without resending anything. Retry execution remains available in the originating tab while it still retains the browser Files or command payload. Closing that tab loses those retry payloads.
Before its first prompt, a new conversation’s composer shows a machine
selector when a remote is connected. It defaults to the machine the
conversation was opened for. Choosing another machine re-points the
conversation at that machine’s matching checkout; the draft text stays and
no session is created by the switch. Matching uses every Git fetch remote,
so checkout paths and remote names can differ. One shared upstream is enough,
including when a fork’s upstream matches another checkout’s origin.
Machines without a matching project are disabled.
Remove any attachments before switching machines; uploaded files belong to
the original host. The first prompt creates the session on the selected
machine, and from then on it stays on its owner.
Managed remotes
By default each remote applies its own settings to its sessions. Auto-approve judging runs on the machine that owns the session, so a remote judges with the judge model, delay and prompt sections from its own Settings page.
Start a remote with -remote-managed to make it use the hub’s settings:
ocman -remote-listen 0.0.0.0:8230 -remote-managed \
-remote-tls-cert cert.pem -remote-tls-key key.pemThe hub sends these settings when it connects and again whenever you change one:
- the default auto-approve state for new sessions (
-auto-approveon the hub) - the judge model
- the judge delay
- the judge prompt sections
The remote saves the last settings it received, so it keeps using them across
restarts and while the hub is disconnected. Until a hub first connects it
uses its own settings. The remote’s own values are not overwritten: start
it without -remote-managed to use them again.
On a managed remote, these fields cannot be changed from its own Settings page. Settings → Remotes → This machine shows which hub manages it. On the hub, each connected remote shows whether it uses the hub’s settings:
| Status | Meaning |
|---|---|
| Uses this hub’s auto-approve settings | The remote applied the hub’s settings. |
| Uses its own settings (start it with -remote-managed…) | The remote runs without -remote-managed. |
| Uses its own settings (update ocman…) | The remote’s ocman is too old to accept settings. |
| Could not send settings | Sending failed; the remote keeps the last settings it received. |
Use one hub per managed remote. Ocman does not enforce this. If several hubs attach to the same managed remote, each one replaces the settings when it connects or changes a setting, and the remote logs a warning.
Settings that belong to the machine never sync: tokens and credentials, the
judge endpoint and its API key, provider and forge logins, installed
platforms, Claude hooks and plugins. A managed remote with its own judge
endpoint keeps using that endpoint and its model instead of the hub’s judge
model. The judge model must also be available on the remote. The per-session auto-approve switch in
a conversation always applies on the remote, with or without -remote-managed.
Managing a remote lets the hub decide which tool calls that machine approves automatically. Anyone who can attach as a hub can already send prompts there, so this does not grant new access, but only use
-remote-managedon machines whose hubs you trust.
Managing remotes
The hub’s Settings → Remotes page lists each attached remote with its health, hostname, reported instance ID, session count, and last-seen time. Per-remote actions:
- Disable / Enable. Disconnect the remote without deleting its address, token, or display name. While disabled it is unavailable for sessions and host actions, and the hub stops reconnecting to it, including after a restart. Click Enable to connect again with the saved settings. Disabling the connection does not stop agents running on the remote machine.
- Reconnect. Force a fresh dial. This also happens automatically with backoff after a transient drop.
- Edit. Change the display name or address, replace the token, or enable and disable the remote.
- Remove. Detach the remote. Its sessions disappear from the list.
The This machine entry is non-removable, and its address and token cannot be edited.
Security
- Token auth is mandatory on the gRPC channel. A missing or wrong
token is rejected and shown as
auth-failedon the hub. - TLS is the default requirement. Start the remote with both
-remote-tls-certand-remote-tls-key, and use agrpcs://address on the hub. Plaintext requires both-remote-trusted-overlayon the remote and an explicitgrpc://address on the hub; bare addresses are rejected. - Plaintext exposes the bearer token. With
grpc://, the remote-access token and all session traffic are unencrypted. Use this mode only when an encrypted trusted overlay such as Tailscale or WireGuard already protects the complete route between hub and remote. A private LAN alone is not an encrypted trusted overlay. - Stored remote tokens on the hub are encrypted at rest with an app-local key and are never returned to the browser. That protects against casual disclosure, not against an attacker who can read both the state DB and the app-local secret. Ocman enforces owner-only filesystem permissions on these files at startup.
Flags
| Flag | Default | Where | Description |
|---|---|---|---|
-remote-listen | (unset, off) | remote | Bind address for the remote-access gRPC server, e.g. 0.0.0.0:8230. Empty disables it. |
-remote-tls-cert | (unset) | remote | TLS certificate file. Required with -remote-tls-key unless using a trusted overlay. |
-remote-tls-key | (unset) | remote | TLS key file. |
-remote-trusted-overlay | false | remote | Explicitly allow plaintext only on a trusted overlay network. |
-remote-managed | false | remote | Use the auto-approve settings sent by the connected hub. Requires -remote-listen; not supported with -gui. See Managed remotes
. |
The hub needs no flags. You add remotes at runtime from the Settings page,
and ocman persists them in state.db.
Troubleshooting
| Symptom | Likely cause |
|---|---|
Health shows auth-failed | Wrong token, or the remote regenerated its token. Reveal it again on the remote and update it on the hub (Edit). |
Health shows offline | The hub can’t reach the remote’s gRPC address. Check the port, firewall, and overlay network. Sessions appear stale until it reconnects. |
Health shows incompatible-version | Hub and remote are different ocman builds with an incompatible wire protocol. Align versions. |
| Remote connected but no sessions | The remote may simply have none, or its OpenCode database isn’t where it expects. Check the remote’s own dashboard. |
| New-session picker never finds a remote’s project | The remote’s project inventory refreshes on connect and periodically, so a freshly checked-out project may take a moment to appear. |
Limitations (v1)
- Auto-approve for a remote session runs on the owning remote. It uses that
machine’s settings unless the remote runs with
-remote-managed. - Stale sessions from an offline remote are kept in memory only. After a hub restart an offline remote shows no sessions until it reconnects.