Manage SSH server connections directly within opencode. Connect to remote servers, and all commands automatically target the remote environment.
| Command | Description |
|---|---|
/ssh |
List saved servers and connect to one |
/ssh-disconnect |
Disconnect from the current SSH server |
/ssh-add |
Add a new SSH server configuration |
/ssh-edit |
Edit or delete SSH server configurations |
- Copy this plugin directory into your project
- Ensure
opencode.jsonreferences the plugin:{ "$schema": "https://opencode.ai/config.json", "plugin": ["./ssh-plugin.ts"] } - Restart opencode
# Add a server
/ssh-add
# Connect to a server
/ssh
# Work normally - commands target the remote server
# Disconnect when done
/ssh-disconnectThe AI will ask for:
- Server name - unique identifier
- Hostname/IP - server address
- Username - SSH login user
- Auth - password, key file path, or SSH agent
- Port - default 22
- Remote folder - working directory on the server
- Environment - OS, runtime versions, etc.
- Description - optional notes
Select a server from the list. The plugin:
- Tests the SSH connection
- Sets the active connection in
ssh.json - Injects connection context into the AI's system prompt
Once connected, the AI knows it's working on a remote server and will execute commands via SSH automatically.
When connected, the following information is injected at the end of the system prompt (preserving max prefix cache):
- Server name, host, username, port
- Remote folder path
- Environment details
- SSH/SCP/rsync command templates
- Edit - modify any field of an existing server
- Delete - remove a server (with confirmation)
- View - display all server configurations
{
"servers": [
{
"name": "production",
"host": "192.168.1.100",
"username": "deploy",
"port": 22,
"remoteFolder": "/var/www/app",
"environment": "Ubuntu 22.04, Node.js 18, Docker 24",
"description": "Production web server"
},
{
"name": "dev-vm",
"host": "192.168.1.50",
"username": "dev",
"keyFile": "~/.ssh/id_rsa",
"port": 22,
"remoteFolder": "/home/dev/project",
"environment": "Ubuntu 24.04, Python 3.12",
"description": "Development VM"
}
],
"activeConnection": {
"serverName": "production",
"connectedAt": "2025-01-15T10:30:00.000Z"
}
}ssh.jsonmay contain passwords in plain text. Prefer SSH key authentication.ssh.jsonis included in.gitignoreby default.- For production, use SSH key files or SSH agent instead of passwords.
opencode-ssh/
├── opencode.json # Plugin configuration
├── ssh-plugin.ts # Plugin source
├── ssh.json # Server data (auto-managed)
├── ssh.example.json # Example configuration
├── package.json # Dependencies
├── .gitignore # Ignore sensitive files
└── README.md # This file
- opencode with plugin support
- SSH client installed locally
- Network access to target servers