OpenClaw Tailscale Remote Access
Use this skill when Codex needs to make an OpenClaw gateway reachable over Tailscale and the result must be directly configurable, not just described.
Prefer Tailscale Serve + HTTPS for browser access. The recommended shape is:
- - OpenClaw binds to INLINECODE1
- Browser access goes through INLINECODE2
- INLINECODE3 is INLINECODE4
- INLINECODE5 is INLINECODE6
Required Inputs
Collect these values before making changes:
- - a non-Tailscale access path to the Linux host
cloud console or public SSH is preferred
- - the OpenClaw config file path
default:
~/.openclaw/openclaw.json
- - the final MagicDNS hostname
example:
<machine>.<tailnet>.ts.net
- - the gateway token to place in the config
Skill Resources
Resolve the skill directory first so Codex can call the bundled scripts even if the skill is still in ~/Downloads:
CODEBLOCK0
Safety Rules
- 1. Do not run
tailscale up from a Tailscale SSH session. - If you need to change Tailscale state, prefer a cloud console or public SSH session.
- Do not switch OpenClaw to
bind: "tailnet" unless the user explicitly accepts HTTP-only access and weaker browser behavior. - On a Mac client, keep Tailscale DNS enabled if the browser must resolve
*.ts.net.
Direct Workflow
1. Inspect Current State
Run the bundled inspector first:
CODEBLOCK1
Use the output to answer these questions before changing anything:
- - is
openclaw-gateway running - is Tailscale running
- is an HTTPS Serve handler already present
- are there pending pairing requests
2. Confirm the Session Is Safe For tailscale up
Use these checks:
CODEBLOCK2
If the current shell is reached through Tailscale SSH or through a Tailscale IP, stop and switch to cloud console or public SSH before changing Tailscale state.
3. Apply the OpenClaw Gateway Config
The bundled script creates a timestamped backup and updates only the gateway fields needed for remote access:
CODEBLOCK3
The script enforces this shape:
CODEBLOCK4
4. Restart The Gateway
CODEBLOCK5
If the service does not return to active (running), fix that before touching Tailscale Serve.
5. Start Or Repair Tailscale In Low-Impact Mode
Use this only from a safe session:
CODEBLOCK6
If Tailscale says all non-default flags must be restated, rerun tailscale up with the existing non-default flags plus the flags above. Do not use --reset blindly.
6. Configure HTTPS Serve
Use the bundled helper:
CODEBLOCK7
If the node already has Serve config that must be replaced, rerun with:
CODEBLOCK8
Expected mapping:
CODEBLOCK9
7. Validate End To End
Run these checks in order:
CODEBLOCK10
Expected results:
- - Tailscale backend is INLINECODE18
- Serve reports an HTTPS handler on TCP 443
- INLINECODE19 is INLINECODE20
- the HTTPS request reaches the service and does not fail at DNS or TLS handshake
Client Repair
If the browser client is a Mac and *.ts.net stopped resolving after Tailscale changes, do not change the server bind mode. Repair the client first:
CODEBLOCK11
Pairing Required
If the dashboard loads but reports pairing required:
CODEBLOCK12
If the CLI path is broken, inspect the installed OpenClaw CLI or Python package on the host and call its built-in approval path. Do not manually edit pending.json or paired.json unless the user explicitly asks for a last-resort recovery.
Troubleshooting Priorities
controlUi.allowedOrigins is wrong; re-run the config script with the correct
TS_HOSTNAME.
- -
ERR_SSL_PROTOCOL_ERROR, invalid response, or TLS handshake failure
Check
tailscale serve status, then inspect host DNS and certificate issuance.
- -
NXDOMAIN for *.ts.net on the client
Fix client MagicDNS; do not switch the server to
bind: "tailnet" just to bypass DNS.
Approve the pending device on the gateway host.
References
OpenClaw Tailscale 远程访问
当 Codex 需要通过 Tailscale 使 OpenClaw 网关可达,且结果必须可直接配置而不仅仅是描述时,使用此技能。
浏览器访问优先使用 Tailscale Serve + HTTPS。推荐配置如下:
- - OpenClaw 绑定到 127.0.0.1
- 浏览器访问通过 https://..ts.net
- auth.mode 为 token
- auth.allowTailscale 为 true
必需输入
在进行更改前收集以下值:
- - 访问 Linux 主机的非 Tailscale 路径
优先使用云控制台或公共 SSH
默认:~/.openclaw/openclaw.json
示例:
..ts.net
技能资源
先解析技能目录,以便 Codex 能调用捆绑脚本,即使技能仍在 ~/Downloads 中:
bash
export SKILLDIR=${CODEXHOME:-$HOME/.codex}/skills/openclaw-tailscale-remote-access
if [ ! -d $SKILL_DIR ] && [ -d $HOME/Downloads/openclaw-tailscale-remote-access ]; then
export SKILL_DIR=$HOME/Downloads/openclaw-tailscale-remote-access
fi
export OPENCLAWCONFIG=${OPENCLAWCONFIG:-$HOME/.openclaw/openclaw.json}
export GATEWAYPORT=${GATEWAYPORT:-18789}
export TS_HOSTNAME=..ts.net
export GATEWAY_TOKEN=
安全规则
- 1. 不要从 Tailscale SSH 会话中运行 tailscale up。
- 如果需要更改 Tailscale 状态,优先使用云控制台或公共 SSH 会话。
- 除非用户明确接受仅 HTTP 访问和较弱的浏览器行为,否则不要将 OpenClaw 切换到 bind: tailnet。
- 在 Mac 客户端上,如果浏览器必须解析 *.ts.net,请保持 Tailscale DNS 启用。
直接工作流程
1. 检查当前状态
首先运行捆绑的检查器:
bash
bash $SKILLDIR/scripts/inspectremoteaccess.sh $OPENCLAWCONFIG
在进行任何更改前,使用输出来回答以下问题:
- - openclaw-gateway 是否正在运行
- Tailscale 是否正在运行
- 是否已存在 HTTPS Serve 处理程序
- 是否有待处理的配对请求
2. 确认会话对 tailscale up 安全
使用以下检查:
bash
printf SSHCONNECTION=%s\n ${SSHCONNECTION:-}
hostname
tailscale ip -4 2>/dev/null || true
如果当前 shell 是通过 Tailscale SSH 或 Tailscale IP 访问的,请停止并在更改 Tailscale 状态前切换到云控制台或公共 SSH。
3. 应用 OpenClaw 网关配置
捆绑脚本会创建带时间戳的备份,并仅更新远程访问所需的网关字段:
bash
python3 $SKILLDIR/scripts/applygateway_config.py \
--config $OPENCLAW_CONFIG \
--ts-hostname $TS_HOSTNAME \
--token $GATEWAY_TOKEN \
--port $GATEWAY_PORT
脚本强制执行以下配置格式:
json
{
gateway: {
port: 18789,
mode: local,
bind: loopback,
controlUi: {
allowedOrigins: [
http://localhost:18789,
http://127.0.0.1:18789,
https://..ts.net
]
},
auth: {
mode: token,
token: ,
allowTailscale: true
},
tailscale: {
mode: serve,
resetOnExit: false
}
}
}
4. 重启网关
bash
systemctl --user restart openclaw-gateway
systemctl --user status openclaw-gateway --no-pager
如果服务未恢复到 active (running) 状态,请在操作 Tailscale Serve 前修复此问题。
5. 以低影响模式启动或修复 Tailscale
仅在安全会话中使用此命令:
bash
tailscale up --accept-dns=false --accept-routes=false --ssh=false
如果 Tailscale 提示必须重新声明所有非默认标志,请使用现有非默认标志加上上述标志重新运行 tailscale up。不要盲目使用 --reset。
6. 配置 HTTPS Serve
使用捆绑的辅助脚本:
bash
bash $SKILLDIR/scripts/configuretailscaleserve.sh --port $GATEWAYPORT
如果节点已有需要替换的 Serve 配置,请重新运行:
bash
bash $SKILLDIR/scripts/configuretailscaleserve.sh --reset-first --port $GATEWAYPORT
预期映射:
text
https://..ts.net/ -> http://127.0.0.1:18789/
7. 端到端验证
按顺序运行以下检查:
bash
tailscale status --json
tailscale serve status --json
systemctl --user status openclaw-gateway --no-pager
tailscale ip -4
curl -vkI --resolve $TSHOSTNAME:443:$(tailscale ip -4 | head -n1) https://$TSHOSTNAME/
预期结果:
- - Tailscale 后端状态为 Running
- Serve 报告 TCP 443 上有 HTTPS 处理程序
- openclaw-gateway 状态为 active (running)
- HTTPS 请求到达服务,且 DNS 和 TLS 握手未失败
客户端修复
如果浏览器客户端是 Mac,且 Tailscale 更改后 *.ts.net 停止解析,不要更改服务器绑定模式。先修复客户端:
bash
tailscale set --accept-routes=false
tailscale set --accept-dns=true
scutil --dns | grep -E ts.net|tailscale
nslookup $TS_HOSTNAME
需要配对
如果仪表板加载但报告 pairing required:
bash
cat ~/.openclaw/devices/pending.json
openclaw devices list
openclaw devices approve
如果 CLI 路径损坏,请检查主机上安装的 OpenClaw CLI 或 Python 包,并调用其内置的批准路径。除非用户明确要求作为最后手段恢复,否则不要手动编辑 pending.json 或 paired.json。
故障排除优先级
controlUi.allowedOrigins 错误;使用正确的 TS_HOSTNAME 重新运行配置脚本。
- - ERRSSLPROTOCOL_ERROR、invalid response 或 TLS 握手失败
检查 tailscale serve status,然后检查主机 DNS 和证书颁发。
- - 客户端上 *.ts.net 出现 NXDOMAIN
修复客户端 MagicDNS;不要仅仅为了绕过 DNS 而将服务器切换到 bind: tailnet。
在网关主机上批准待处理的设备。
参考