用一台平板,开发公司的 GPU 集群 Driving a corporate GPU cluster from a tablet — over one reverse SSH tunnel

没有公网 IP、没有 VPN 网关、没有额外客户端。一台最低配云主机 + 一条常驻反向隧道。

链路 · The chain

四跳,每一跳都只做一件事。

Four hops. Each one does exactly one thing.

📱 OPPO Pad mini终端而已 —— 一个 SSH App,敲字、看日志。Just a keyboard and a screen.
公网 SSH · public internet
☁️ 腾讯云轻量服务器唯一有公网 IP 的角色,跑 frps,只做端口转发。The only public-facing box.
反向隧道(由 Mac 主动建立)· reverse tunnel, dialed out by the Mac
💻 家里的 Mac真正的工作机:Claude Code、git、编辑器都在这。The actual dev machine.
公司内网 · corporate network
🖥️ 公司 GPU 集群训练、推理、数据处理。Where the real compute lives.
关键点:Mac 主动拨出到云主机,所以家里的路由器不需要开任何端口,也不用公网 IP。
The Mac dials out. Nothing at home needs to be port-forwarded or publicly addressable.

搭建 · Setup

  1. 云主机上开 frps 的 SSH 网关

    frp 自带 SSH Tunnel Gateway,客户端因此不用装 frpc,系统自带的 ssh 就够了。

    # /etc/frp/frps.toml  —— on the Tencent Cloud VPS
    bindPort = 7000
    auth.token = "<YOUR_TOKEN>"
    
    [sshTunnelGateway]
    bindPort = 2200
  2. Mac 把自己的 22 端口反向注册上去

    一条命令,把 Mac 的 SSH 端口映射成云主机的 6000

    ssh -R :6000:127.0.0.1:22 v0@<VPS_IP> -p 2200 \
        tcp --proxy_name home-mac --remote_port 6000 --token <YOUR_TOKEN>

    前提:Mac 打开「系统设置 → 通用 → 共享 → 远程登录」。
    Requires Remote Login enabled on macOS.

  3. 用 launchd 让这条隧道永不掉线

    断网、重启、休眠唤醒后自动重连。这一步决定了它是「玩具」还是「能用的东西」。

    <!-- ~/Library/LaunchAgents/com.me.frp-ssh-tunnel.plist -->
    <key>RunAtLoad</key>   <true/>
    <key>KeepAlive</key>
    <dict>
      <key>NetworkState</key>    <true/>   <!-- 有网就拉起 -->
      <key>SuccessfulExit</key>  <false/>  <!-- 退出就重来 -->
    </dict>

    SSH 侧再配 ServerAliveInterval 30 + ExitOnForwardFailure yes, 让半死的连接尽快失败、尽快被 launchd 重建。
    Fail fast, restart fast — that is the whole trick.

  4. 平板直接连

    任意 SSH 客户端,连云主机的 6000 端口,落地就是家里的 Mac。

    ssh me@<VPS_IP> -p 6000

    进去之后开 tmux,跑 Claude Code、gitsbatch —— 和坐在电脑前完全一样。

三个坑 · Three gotchas

问题 Problem处理 Fix
Mac 上开着 VPN 代理 → 慢到没法用 最容易踩、也最影响体验的一个。VPN 客户端会接管系统路由,隧道的出向流量被绕去 VPN 网关再折返,往返路径被拉长几倍 —— 表现为打字回显延迟、日志滚动一顿一顿,但机器本身并不慢。
做法:在 VPN 的分流 / 排除规则里让云主机地址走直连;或在不需要访问内网时先断开 VPN。VPN 重连会打断隧道,launchd 会自动重建。
A VPN client that takes over routing pushes the tunnel's traffic out through its gateway and back, stretching the round trip — keystroke echo and log scrolling turn laggy. Exclude the cloud host from the VPN's split-tunnel rules, or disconnect the VPN when you don't need internal access.
Mac 睡眠后隧道断 caffeinate 或电源设置阻止休眠;注意 App Nap 会冻结后台进程的保活计时器,终端 App 需排除在外。
Prevent sleep; exclude the terminal app from App Nap.
端口暴露在公网 Mac 只开公钥登录(禁密码)、云主机装 fail2ban、隧道端口用安全组限制来源 IP。
Key-only auth, fail2ban, and a source-IP allowlist on the tunnel port.