OpenClaw从入门到应用——CLI:设备
通过OpenClaw实现副业收入:《OpenClaw赚钱实录:从“养龙虾“到可持续变现的实践指南》
openclaw devices
管理设备配对请求和设备作用域令牌。
命令
openclaw devices list
列出待处理的配对请求和已配对的设备。
openclaw devices list openclaw devices list --jsonopenclaw devices remove <deviceId>
移除一个已配对的设备条目。
openclaw devices remove <deviceId> openclaw devices remove <deviceId> --jsonopenclaw devices clear --yes [--pending]
批量清除已配对的设备。
openclaw devices clear --yes openclaw devices clear --yes --pending openclaw devices clear --yes --pending --jsonopenclaw devices approve [requestId] [--latest]
批准一个待处理的设备配对请求。如果省略requestId,OpenClaw 将自动批准最近的待处理请求。
openclaw devices approve openclaw devices approve <requestId> openclaw devices approve --latestopenclaw devices reject <requestId>
拒绝一个待处理的设备配对请求。
openclaw devices reject <requestId>openclaw devices rotate --device <deviceId> --role <role> [--scope <scope>]
为特定角色轮换设备令牌(可选更新作用域)。此操作通常用于安全维护或令牌泄露后的恢复。
openclaw devices rotate --device <deviceId> --role operator --scope operator.read --scope operator.writeopenclaw devices revoke --device <deviceId> --role <role>
撤销特定角色的设备令牌。撤销后,该设备将无法再以该角色身份访问系统,需重新配对或轮换令牌。
openclaw devices revoke --device <deviceId> --role node通用选项
--url <url>:网关 WebSocket URL(配置时默认为gateway.remote.url)。--token <token>:网关令牌(如果需要)。--password <password>:网关密码(密码认证)。--timeout <ms>:RPC 超时时间(毫秒)。--json:JSON 格式输出(推荐用于脚本编写)。
注意:当您设置--url时,CLI 不会回退到配置文件或环境变量中的凭据。请显式传递--token或--password。缺少显式凭据将被视为错误。
注意事项
- 令牌轮换会返回一个新的令牌(敏感信息)。请像对待密钥一样妥善保管。
- 这些命令需要
operator.pairing(或operator.admin)作用域权限。 devices clear命令故意设置了--yes标志作为安全门控,以防止误操作。- 如果在本地回环地址上无法使用配对作用域(且未传递显式
--url),list/approve 命令可以使用本地配对回退机制。
令牌漂移恢复检查清单
当控制 UI 或其他客户端持续因AUTH_TOKEN_MISMATCH或AUTH_DEVICE_TOKEN_MISMATCH错误而连接失败时,请使用此检查清单进行排查。
确认当前网关令牌来源:
openclaw config get gateway.auth.token列出已配对的设备并识别受影响的设备 ID:
openclaw devices list为受影响的设备轮换操作员令牌:
openclaw devices rotate--device<deviceId>--roleoperator如果轮换不足以解决问题,请移除过期的配对并重新批准:
openclaw devices remove<deviceId>openclaw devices list openclaw devices approve<requestId>使用当前的共享令牌/密码重试客户端连接。
相关内容:
- 仪表板认证故障排除
- 网关故障排除
