File contents ssh-tunnel
功能
管理SSH端口转发与代理通道,含生命周期管理。
配置
参考config.example.yaml的tunnels段,profile引用connect配置。
使用
bash tunnel/scripts/ssh-tunnel.sh forward <profile> <lport>:<rhost>:<rport>
bash tunnel/scripts/ssh-tunnel.sh reverse <profile> <rport>:<lhost>:<lport>
bash tunnel/scripts/ssh-tunnel.sh socks <profile> <local_port>
bash tunnel/scripts/ssh-tunnel.sh proxy <profile> [--local-proxy-port 7890]
bash tunnel/scripts/ssh-tunnel.sh list
bash tunnel/scripts/ssh-tunnel.sh stop <tunnel_id>
bash tunnel/scripts/ssh-tunnel.sh stop-all
自动触发规则
Agent 必须遵守以下规则,遇到对应场景时主动使用 tunnel 功能:
反向代理(proxy)— 远程服务器无外网时自动启用
当远程服务器上出现以下任一情况时,必须立即使用 proxy 命令建立反向代理 ,而不是尝试绕过(如从其他环境拷贝包、用符号链接等 workaround):
触发信号
示例
pip/conda install 超时或连接失败
Connection timed out, Could not fetch URL, ReadTimeoutError
git clone/fetch 超时或连接拒绝
port 443: Connection timed out, fatal: unable to access
curl/wget 无法访问外部 URL
Connection refused, Could not resolve host
任何需要从外网下载资源但失败的场景
npm install、apt-get、yum install 等
操作流程 :
检查本地是否有可用代理(检查本地的 http_proxy/https_proxy 环境变量,或常见代理端口如 7890、1080)
用 proxy 命令建立反向代理隧道:bash tunnel/scripts/ssh-tunnel.sh proxy <profile>
在后续远程命令中设置代理环境变量(proxy 命令输出的 export 语句)
重试之前失败的网络操作
任务完成后用 stop-all 清理隧道
禁止的替代方案 :
不要从其他 conda 环境符号链接/拷贝已安装的包
不要跳过安装步骤
不要使用 .pth 文件指向其他环境的包
这些 workaround 会导致依赖不完整、版本冲突等问题
端口转发(forward)— 访问远程服务
当需要从本地访问远程服务器上的端口时使用(如远程数据库、Web UI、TensorBoard 等)。
SOCKS 代理(socks)— 本地通过远程访问网络
当需要通过远程服务器作为跳板访问特定网络时使用。
注意事项
隧道记录在~/.ssh/tunnels.json,list自动清理失效进程
proxy输出远程端需执行的环境变量命令
成功返回0,失败返回非0
建立 proxy 后,远程命令需要在同一 shell 会话中 export 代理环境变量才能生效
Token约束
隧道列表:已足够精简,无需优化
状态检查:只输出关键信息(端口、PID、状态)
重复信息:不复述已知内容
1 --- 2 name: ssh-dev-suite-tunnel 3 description: Ssh Dev Suite Tunnel 4 --- 5 6 # ssh-tunnel 7 8 ## 功能 9 管理SSH端口转发与代理通道,含生命周期管理。 10 11 ## 配置 12 参考`config.example.yaml`的tunnels段,profile引用connect配置。 13 14 ## 使用 15 ```bash 16 bash tunnel/scripts/ssh-tunnel.sh forward <profile> <lport>:<rhost>:<rport> 17 bash tunnel/scripts/ssh-tunnel.sh reverse <profile> <rport>:<lhost>:<lport> 18 bash tunnel/scripts/ssh-tunnel.sh socks <profile> <local_port> 19 bash tunnel/scripts/ssh-tunnel.sh proxy <profile> [--local-proxy-port 7890] 20 bash tunnel/scripts/ssh-tunnel.sh list 21 bash tunnel/scripts/ssh-tunnel.sh stop <tunnel_id> 22 bash tunnel/scripts/ssh-tunnel.sh stop-all 23 ``` 24 25 ## 自动触发规则 26 27 **Agent 必须遵守以下规则,遇到对应场景时主动使用 tunnel 功能:** 28 29 ### 反向代理(proxy)— 远程服务器无外网时自动启用 30 31 当远程服务器上出现以下任一情况时,**必须立即使用 `proxy` 命令建立反向代理**,而不是尝试绕过(如从其他环境拷贝包、用符号链接等 workaround): 32 33 | 触发信号 | 示例 | 34 |----------|------| 35 | pip/conda install 超时或连接失败 | `Connection timed out`, `Could not fetch URL`, `ReadTimeoutError` | 36 | git clone/fetch 超时或连接拒绝 | `port 443: Connection timed out`, `fatal: unable to access` | 37 | curl/wget 无法访问外部 URL | `Connection refused`, `Could not resolve host` | 38 | 任何需要从外网下载资源但失败的场景 | npm install、apt-get、yum install 等 | 39 40 **操作流程**: 41 1. 检查本地是否有可用代理(检查本地的 `http_proxy`/`https_proxy` 环境变量,或常见代理端口如 7890、1080) 42 2. 用 `proxy` 命令建立反向代理隧道:`bash tunnel/scripts/ssh-tunnel.sh proxy <profile>` 43 3. 在后续远程命令中设置代理环境变量(proxy 命令输出的 export 语句) 44 4. 重试之前失败的网络操作 45 5. 任务完成后用 `stop-all` 清理隧道 46 47 **禁止的替代方案**: 48 - 不要从其他 conda 环境符号链接/拷贝已安装的包 49 - 不要跳过安装步骤 50 - 不要使用 `.pth` 文件指向其他环境的包 51 - 这些 workaround 会导致依赖不完整、版本冲突等问题 52 53 ### 端口转发(forward)— 访问远程服务 54 55 当需要从本地访问远程服务器上的端口时使用(如远程数据库、Web UI、TensorBoard 等)。 56 57 ### SOCKS 代理(socks)— 本地通过远程访问网络 58 59 当需要通过远程服务器作为跳板访问特定网络时使用。 60 61 ## 注意事项 62 - 隧道记录在`~/.ssh/tunnels.json`,list自动清理失效进程 63 - proxy输出远程端需执行的环境变量命令 64 - 成功返回0,失败返回非0 65 - 建立 proxy 后,远程命令需要在同一 shell 会话中 export 代理环境变量才能生效 66 67 ## Token约束 68 - 隧道列表:已足够精简,无需优化 69 - 状态检查:只输出关键信息(端口、PID、状态) 70 - 重复信息:不复述已知内容
zht043/AgentSkills/tree/main/skills/ssh-dev-suite/tunnel commit b866f64c78
Frequently asked questions How do I install the Ssh Dev Suite/tunnel skill? Run npx skillmds@latest add zht043/ssh-dev-suite-tunnel in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Ssh Dev Suite/tunnel skill do? Ssh Dev Suite Tunnel It is listed under Coding & Dev Tools on SkillMD.
Is Ssh Dev Suite/tunnel safe to use? This skill has not completed SkillMD's automated safety review yet. Capability flags: executes scripts, makes network calls, reads secrets. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Ssh Dev Suite/tunnel? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Ssh Dev Suite/tunnel free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Ssh Dev Suite/tunnel? zht043 (@zht043) published this skill. Their other Agent Skills are listed on their SkillMD profile.