安全配置
OpenClaw 运行在你的设备上,拥有执行命令和访问文件的能力,安全配置至关重要。
DM 策略
控制谁可以与你的 Agent 交互:
json
// ~/.openclaw/openclaw.json
{
"dmPolicy": "pairing"
}| 策略 | 说明 |
|---|---|
pairing(默认) | 未知用户需要配对码才能交互 |
open | 任何人都可以交互(危险) |
DANGER
永远不要在公网环境使用 open 策略,否则任何人都可以通过你的 Agent 执行命令。
配对管理
bash
# 查看待批准的配对请求
openclaw pairing list
# 批准配对
openclaw pairing approve <channel> <code>
# 撤销配对
openclaw pairing revoke <channel> <user>沙箱隔离
OpenClaw 支持在 Docker 容器中执行工具调用:
json
{
"agents": {
"defaults": {
"sandbox": {
"enabled": true,
"scope": "tools",
"workspace": "/workspace"
}
}
}
}网络安全
- 不要将 Gateway 端口(18789)暴露到公网
- 使用反向代理(nginx)+ SSL 保护 Dashboard
- 定期更新 OpenClaw 到最新版本
反向代理配置示例
nginx
server {
listen 443 ssl;
server_name openclaw.example.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://127.0.0.1:18789;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}安全检查清单
- [ ] DM 策略设为
pairing - [ ] Gateway 端口未暴露到公网
- [ ] 启用沙箱隔离
- [ ] API Key 存储在
.env文件中(非明文配置) - [ ] 定期检查
openclaw doctor - [ ] 保持版本更新