0
711
近 7 天 87
37.4
生态多维模型
9 天前
2026-09-26
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-plugin-ssh@0.2.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-plugin-ssh@0.2.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-plugin-sshOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode plugin for persistent SSH connections, interactive PTY shells, SFTP file operations, and remote background job management.
Features
- Persistent SSH Sessions: Reuses open connections in memory without repeating handshakes.
- PTY Shell & Multiplexed Exec: Run single discrete commands or maintain state across commands in a persistent shell.
- SFTP File Management: Read, write, and perform targeted search-and-replace edits on remote files.
- Pager Guard: Automatically sets
TERM=dumb,PAGER=cat, andCI=1to prevent interactive hangs. - Key & Passphrase Support: Reads private keys from disk or options, supporting passphrases and environment variables.
- Detached Background Jobs: Spawn, inspect, fetch logs, and terminate long-running remote processes.
- Cluster Broadcast: Execute commands across multiple active sessions concurrently.
- System Diagnostics: Single-call probe gathering OS, hardware, runtime, and network info.
Installation
Add to your OpenCode configuration (opencode.json or ~/.config/opencode/opencode.jsonc):
{
"plugin": [
"opencode-plugin-ssh"
]
}
Or install as a dependency:
npm install -D opencode-plugin-ssh
You can also install directly from GitHub:
{
"plugin": [
"git+https://github.com/maik205/opencode-ssh.git"
]
}
Tools
All tools are registered under the ssh namespace:
Sessions & Connections
ssh_list_profiles: List profiles from~/.ssh/configand saved configurations.ssh_save_profile: Store host connection parameters for quick reuse.ssh_connect: Open or verify an active SSH session.ssh_list_sessions: List connected sessions and their active status.ssh_switch_session: Change the default active session.ssh_close: Disconnect and clean up a session.ssh_broadcast: Run a command across multiple connected sessions.
Execution & PTY
ssh_exec: Run a non-interactive command and return stdout, stderr, exit code, andexecutedAs.ssh_interactive_cmd: Execute commands inside a persistent PTY shell (returns output andexecutedAs).ssh_switch_user: Switch user (e.g. toroot) in the persistent shell viasudo/suwith automatic password handling.ssh_pty_send: Send raw text or control characters (e.g.\x03) to the PTY.ssh_pty_read: Retrieve recent buffer output from the PTY shell.
Filesystem (SFTP & SCP)
ssh_scp: Securely copy files or directories between local machine and remote host (upload/download), or stream directly between two remote sessions (remote_to_remote) with recursive and high-throughput chunked transfer support.ssh_read_file: Read remote files with pagination and line numbering.ssh_write_file: Write or overwrite remote files over SFTP.ssh_edit_file: Find and replace exact substrings within remote files.ssh_list_dir: Structured directory listing (name, size, mode, permissions, isDirectory, isSymlink, mtime).ssh_stat: Inspect file/directory metadata or test for existence (size, permissions, timestamps, link targets).ssh_mkdir: Create remote directory with optional recursive creation of parent directories (-p).ssh_rm: Delete a remote file or folder with optional recursive directory removal.ssh_rename: Move or rename remote files and directories over SFTP.ssh_chmod: Change remote file/directory permissions via octal mode (e.g.'0755','0644','0600').
Background Jobs & Health
ssh_system_inspect: Inspect system metrics, listening ports, and installed runtimes.ssh_job_spawn: Start a supervised background job.ssh_job_status: Check status and exit code of a spawned job.ssh_job_logs: Fetch stdout and stderr output from a background job.ssh_job_kill: Terminate a background job with a specified signal.
License
同类生态推荐
Cockpit
opencode-cockpit
OpenCode superpowers, all in one: installs every opencode-cockpit feature (Shell, Statusline, Review, Updater, Subagents, Trail, Trust), each can be switched off
Subagents
@opencode-cockpit/subagents
See what your subagents are doing: in the sidebar, full screen, and message them
Pty
opencode-pty
OpenCode plugin for interactive PTY management - run background processes, send input, read output with regex filtering