远程访问
从远程位置访问 OpenClaw 网关。
方式
SSH 隧道
最简单的远程访问方式:
bash
ssh -N -L 18789:127.0.0.1:18789 user@host然后本地访问:
http://127.0.0.1:18789/?token=your-tokenTailscale(推荐)
使用 Tailscale 私有网络:
bash
# 启动时启用 Tailscale Serve
openclaw gateway --tailscale serve
# 或 Funnel(公网访问)
openclaw gateway --tailscale funnel配置:
json
{
"gateway": {
"bind": "tailnet",
"auth": {
"allowTailscale": true
}
}
}直接绑定(不推荐)
绑定到局域网或公网(需要额外安全措施):
json
{
"gateway": {
"bind": "lan",
"auth": {
"token": "strong-token"
}
}
}远程模式设置
在客户端机器上:
bash
openclaw setup --mode remote --remote-url ws://192.168.1.100:18789 --remote-token your-token节点连接
远程节点连接到网关:
bash
openclaw node run --host gateway-host --port 18789或作为服务安装:
bash
openclaw node install --host gateway-host --port 18789TLS 配置
远程访问应启用 TLS:
json
{
"gateway": {
"tls": {
"enabled": true,
"cert": "/path/to/cert.pem",
"key": "/path/to/key.pem"
}
}
}节点连接时验证:
bash
openclaw node run --host gateway-host --tls --tls-fingerprint sha256:xxx防火墙
如果需要开放端口:
bash
# Linux (ufw)
sudo ufw allow 18789/tcp
# macOS
# 系统偏好设置 > 安全性与隐私 > 防火墙最佳实践
- 优先使用 SSH 隧道或 Tailscale
- 始终启用认证
- 远程访问启用 TLS
- 避免直接暴露到公网
- 使用强 token