openclaw secrets
管理密钥和敏感信息。
概要
bash
openclaw secrets <子命令> [选项]描述
openclaw secrets 命令用于安全管理 OpenClaw 使用的各类密钥和敏感信息,如 API Key、访问令牌、数据库密码等。所有密钥均以加密方式存储在本地,运行时自动注入为环境变量供 Agent 和插件使用。
子命令
| 子命令 | 说明 |
|---|---|
set <key> <value> | 设置密钥 |
get <key> | 获取密钥值 |
list | 列出所有密钥(不显示值) |
delete <key> | 删除密钥 |
import <file> | 从 .env 文件批量导入 |
export | 导出密钥列表(仅键名) |
选项
| 选项 | 缩写 | 说明 | 默认值 |
|---|---|---|---|
--show | 显示密钥明文值(与 get/list 配合) | false | |
--format <type> | 输出格式:text、json | text | |
--env-file <path> | 指定 .env 文件路径 | .env |
加密存储
密钥存储在 ~/.openclaw/secrets.enc 文件中,使用 AES-256 加密。主密钥基于系统密钥链(macOS Keychain / Windows Credential Manager / Linux Secret Service)保护。
示例
bash
# 设置 API Key
openclaw secrets set OPENAI_API_KEY sk-xxxxxxxxxxxx
# 设置 DeepSeek Key
openclaw secrets set DEEPSEEK_API_KEY ds-xxxxxxxxxxxx
# 查看某个密钥
openclaw secrets get OPENAI_API_KEY --show
# 列出所有密钥(仅显示键名)
openclaw secrets list
# 删除密钥
openclaw secrets delete OPENAI_API_KEY
# 从 .env 文件批量导入
openclaw secrets import .env.production
# 导出密钥名列表
openclaw secrets export注意
openclaw secrets get默认不显示密钥明文,需添加--show参数- 请勿将
secrets.enc文件提交到版本控制系统
相关命令
openclaw security- 安全管理openclaw sandbox- 沙箱管理openclaw config- 配置管理
