Run opencode on a remote server. Say "ssh myHost" and all commands run remotely.
- No need to install opencode remotely or expose API keys on the server.
- Reuses the same open ssh connection for performance, remembers last working folder, remote open docker connections etc.
Use to rapidly investigate incidents on remote servers, troubleshoot, analyze logs, data etc.
1. Copy the plugin
mkdir -p ~/.config/opencode/plugins
cp src/index.ts ~/.config/opencode/plugins/remote.ts2. Create an agent
.opencode/agent/remote.md:
---
description: Run commands on a remote server via SSH
color: primary
mode: primary
---
When the user says "ssh <host>", use `ssh_connect` with the host name.
When they say "local", use `ssh_disconnect`.- Switch to the Remote agent tab.
- Say "ssh myHost" (replace
myHostwith a host from~/.ssh/config). - Ask anything —
bashcommands automatically run on the remote server. - Say "local" to disconnect.
- Opens SSH ControlMaster (
ssh -MNf ...) for a persistent connection. - Hooks into
tool.execute.beforeto wrapbashcalls with SSH at runtime. - Disables local file tools (
read,write,edit,glob,grep) in remote mode. - Injects remote-mode instructions into the system prompt.
Host myHost
Hostname 192.100.100.100
User username
ServerAliveInterval 60
On the remote server, add your public key in ~/.ssh/authorized_keys
With this entry, you say "ssh myHost" to connect. The Host value is the name you use in conversation.