遠端閘道設定
此內容已合併至遠端存取。請參閱該頁面以取得最新指南。
使用遠端閘道執行 OpenClaw.app
Section titled “使用遠端閘道執行 OpenClaw.app”OpenClaw.app 使用 SSH 隧道連線至遠端閘道。本指南將說明如何進行設定。
flowchart TB subgraph Client["Client Machine"] direction TB A["OpenClaw.app"] B["ws://127.0.0.1:18789\n(local port)"] T["SSH Tunnel"]
A --> B B --> T end subgraph Remote["Remote Machine"] direction TB C["Gateway WebSocket"] D["ws://127.0.0.1:18789"]
C --> D end T --> C步驟 1:新增 SSH 設定
Section titled “步驟 1:新增 SSH 設定”編輯 ~/.ssh/config 並新增:
Host remote-gateway HostName <REMOTE_IP> # e.g., 172.27.187.184 User <REMOTE_USER> # e.g., jefferson LocalForward 18789 127.0.0.1:18789 IdentityFile ~/.ssh/id_rsa將 <REMOTE_IP> 和 <REMOTE_USER> 替換為您的實際值。
步驟 2:複製 SSH 金鑰
Section titled “步驟 2:複製 SSH 金鑰”將您的公鑰複製到遠端機器(輸入一次密碼):
ssh-copy-id -i ~/.ssh/id_rsa <REMOTE_USER>@<REMOTE_IP>步驟 3:設定閘道權杖
Section titled “步驟 3:設定閘道權杖”launchctl setenv OPENCLAW_GATEWAY_TOKEN "<your-token>"步驟 4:啟動 SSH 隧道
Section titled “步驟 4:啟動 SSH 隧道”ssh -N remote-gateway &步驟 5:重新啟動 OpenClaw.app
Section titled “步驟 5:重新啟動 OpenClaw.app”# Quit OpenClaw.app (⌘Q), then reopen:open /path/to/OpenClaw.app應用程式現在將透過 SSH 隧道連線至遠端閘道。
登入時自動啟動隧道
Section titled “登入時自動啟動隧道”若要讓 SSH 隧道在您登入時自動啟動,請建立一個 Launch Agent。
建立 PLIST 檔案
Section titled “建立 PLIST 檔案”將此儲存為 ~/Library/LaunchAgents/ai.openclaw.ssh-tunnel.plist:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>Label</key> <string>ai.openclaw.ssh-tunnel</string> <key>ProgramArguments</key> <array> <string>/usr/bin/ssh</string> <string>-N</string> <string>remote-gateway</string> </array> <key>KeepAlive</key> <true/> <key>RunAtLoad</key> <true/></dict></plist>載入 Launch Agent
Section titled “載入 Launch Agent”launchctl bootstrap gui/$UID ~/Library/LaunchAgents/ai.openclaw.ssh-tunnel.plist隧道現在將會:
- 在您登入時自動啟動
- 如果當機則重新啟動
- 在背景持續執行
舊版備註:如果存在,請移除任何殘留的 com.openclaw.ssh-tunnel LaunchAgent。
檢查隧道是否正在執行:
ps aux | grep "ssh -N remote-gateway" | grep -v greplsof -i :18789重新啟動隧道:
launchctl kickstart -k gui/$UID/ai.openclaw.ssh-tunnel停止隧道:
launchctl bootout gui/$UID/ai.openclaw.ssh-tunnel| 元件 | 功能 |
|---|---|
LocalForward 18789 127.0.0.1:18789 | 將本地連接埠 18789 轉送至遠端連接埠 18789 |
ssh -N | SSH 不執行遠端指令(僅進行連接埠轉送) |
KeepAlive | 如果隧道當機則自動重新啟動 |
RunAtLoad | 當代理程式載入時啟動隧道 |
OpenClaw.app 連線到您用戶端機器上的 ws://127.0.0.1:18789。SSH 隧道會將該連線轉送到執行閘道的遠端機器上的連接埠 18789。