远程访问

远程访问(SSH、隧道与 tailnet)

这个仓库支持“通过 SSH 远程”方式:在专用主机(桌面/服务器)上运行一个 Gateway(主控),客户端连接到它。

核心理念

常见 VPN/tailnet 场景(Agent 在哪里)

Gateway 主机 当作“Agent 所在地”。它拥有会话、认证配置、频道和状态。
你的笔记本/桌面(以及节点)连接到这个主机。

1) tailnet 内始终在线的 Gateway(VPS 或家用服务器)

在持续运行的主机上跑 Gateway,并通过 Tailscale 或 SSH 访问。

这适合笔记本经常休眠但你希望 Agent 始终在线的场景。

2) 家用桌面运行 Gateway,笔记本远程控制

笔记本 不运行 Agent,只进行远程连接:

运行手册:[macOS 远程访问(../platforms/mac/remote.html)。

3) 笔记本运行 Gateway,其他机器远程访问

保持 Gateway 本地但安全暴露:

指南:[Tailscale(../gateway/tailscale.html) 与 Web 概览

命令流(什么在什么地方运行)

一个 Gateway 服务拥有状态 + 频道。节点是外围设备。

示例流程(Telegram → 节点):

说明:

SSH 隧道(CLI + 工具)

创建本地隧道到远程 Gateway WS:

ssh -N -L 18789:127.0.0.1:18789 user@host # 中文注释:将本地 18789 转发到远程 Gateway

隧道建立后:

注意:将 18789 替换为你的 gateway.port(或 --port/OPENCLAW_GATEWAY_PORT)。

CLI 远程默认

你可以持久化一个远程目标,让 CLI 默认使用它:

{
  gateway: {
    mode: "remote",
    remote: {
      url: "ws://127.0.0.1:18789",
      token: "your-token" // 中文注释:远程 CLI 访问令牌
    }
  }
}

当 Gateway 仅 loopback 时,保持 URL 为 ws://127.0.0.1:18789 并先打开 SSH 隧道。

通过 SSH 的聊天 UI

WebChat 不再使用独立 HTTP 端口。SwiftUI Chat UI 直接连接 Gateway WebSocket。

macOS 应用“Remote over SSH”

macOS 菜单栏应用可以端到端驱动该设置(远程状态检查、WebChat 和 Voice Wake 转发)。

运行手册:[macOS 远程访问(../platforms/mac/remote.html)。

安全规则(远程/VPN)

短版:保持 Gateway 仅 loopback,除非你确定需要绑定。

深入了解:[安全(../gateway/security.html)。