Skip to content

Commit 8cbfe2c

Browse files
committed
📄 同步资产凭据自动化文档
1 parent 66aa8a6 commit 8cbfe2c

8 files changed

Lines changed: 216 additions & 8 deletions

File tree

‎docs/cli/assets.md‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
sidebar_position: 8
3+
sidebar_label: Assets & Credentials
4+
---
5+
6+
# Asset & Credential Automation
7+
8+
`opsctl` can create every registered built-in asset type through one generic command and can discover existing managed credentials and SSH Agent identities without returning secret material.
9+
10+
## Create an Asset
11+
12+
```bash
13+
opsctl create asset --name <name> [flags]
14+
```
15+
16+
Use `--type` to select a registered built-in type (the default is `ssh`). The selected type owns its required fields, defaults, legal combinations, and unknown-field validation. Run `opsctl help <type>` for its exact configuration contract.
17+
18+
Type-specific configuration can be passed as a JSON object or read from a file:
19+
20+
```bash
21+
opsctl create asset \
22+
--type database \
23+
--name "Production DB" \
24+
--config '{"driver":"mysql","host":"db.internal","username":"app"}' \
25+
--credential-id 4
26+
27+
opsctl create asset \
28+
--type k8s \
29+
--name "Production Cluster" \
30+
--kubeconfig-file ~/.kube/config \
31+
--context production
32+
```
33+
34+
`--config` and `--config-file` are mutually exclusive. Existing convenience flags such as `--host`, `--port`, `--username`, `--driver`, `--database`, `--read-only`, `--ssh-asset`, and the Kubernetes flags remain available. Only explicitly supplied convenience flags override matching non-secret values from generic configuration.
35+
36+
Validation and credential-reference checks finish before desktop approval. The asset is written only after approval succeeds.
37+
38+
## Passwords and Authentication References
39+
40+
The supported secret/reference inputs are mutually exclusive:
41+
42+
| Input | Behavior |
43+
|---|---|
44+
| `--password-stdin` | Reads plaintext from standard input without a prompt or echo. This is the recommended plaintext path. |
45+
| `--password <value>` | Accepts plaintext in argv and prints a warning because the value may be exposed in shell history, process listings, or CI logs. |
46+
| `--credential-id <id>` | Reuses an existing compatible managed password or SSH-key credential. |
47+
| `--agent-source-id <id>` with `--agent-key-fingerprint <fingerprint>` | Selects an existing SSH Agent source and identity for SSH Agent authentication. |
48+
49+
For example:
50+
51+
```bash
52+
printf '%s\n' "$APP_PASSWORD" | \
53+
opsctl create asset --type redis --name cache \
54+
--config '{"host":"redis.internal","username":"default"}' \
55+
--password-stdin
56+
```
57+
58+
Plaintext supplied through `--password-stdin`, `--password`, or an accepted JSON secret field is encrypted in the asset. It does **not** create a reusable managed credential. Create managed passwords and SSH keys explicitly in the desktop key manager, then reference them with `--credential-id`.
59+
60+
Do not put SSH private keys or passphrases into automation configuration. Import the key in the desktop key manager and reference its credential ID. Kubernetes kubeconfig remains encrypted directly in the asset. Asset types without password authentication reject password inputs.
61+
62+
If a JSON config file contains plaintext secrets, restrict its file permissions, do not commit it, and remove it when it is no longer needed.
63+
64+
## Discover Credentials Safely
65+
66+
List the unified key-management inventory:
67+
68+
```bash
69+
opsctl list credentials
70+
opsctl list credentials --type password
71+
opsctl list credentials --type ssh_key
72+
opsctl list credentials --type ssh_agent
73+
```
74+
75+
Every item has an unambiguous typed reference. Use that reference for detail lookup:
76+
77+
```bash
78+
opsctl get credential credential:4
79+
opsctl get credential agent-source:2
80+
```
81+
82+
Bare numeric IDs are rejected for credential detail because managed credentials and SSH Agent sources use different ID spaces.
83+
84+
These commands return identification and usage metadata only. Depending on the kind, that can include names, usernames, fingerprints, key type/size, sanitized comments, availability, referencing assets, and an SSH key's public key. They never return password plaintext or ciphertext, SSH private keys or passphrases, master keys, SSH Agent endpoint values, signatures, or challenge secrets.
85+
86+
AI automation exposes the same safe discovery model through `list_credentials` and `get_credential`, and uses the same asset-write boundary through `put_asset`.
87+
88+
## Approval, Output, and Audit
89+
90+
Approval details and successful asset results omit write-only secrets. The `put_asset` audit producer also writes an allowlisted request projection: password, Secret Access Key, kubeconfig, private-key, and passphrase fields are absent rather than replaced with `<redacted>`.
91+
92+
This special asset-write projection does not describe every audit record. Other audited tools store the command, request, result, and error received by the audit writer, subject to their existing canonical-command, limited-buffer, and truncation behavior. See [Audit & Approval](../guide/audit.md#audit-payload-boundaries).

‎docs/cli/overview.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ Assets can be referenced in all commands by:
6161
| [`ext`](./ext.md) | List installed extensions or execute an extension tool |
6262
| `help` | Show CLI usage, or `opsctl help <asset>` for that asset type's command syntax |
6363
| `session` | Manage approval sessions (start, end, status) |
64-
| `list` | List resources (`assets` or `groups`) |
65-
| `get` | Get detailed information about a resource |
66-
| `create` | Create a supported SSH, database, Redis, MongoDB, or Kubernetes asset, or a group |
64+
| [`list`](./assets.md#discover-credentials-safely) | List assets, groups, or safe credential metadata |
65+
| [`get`](./assets.md#discover-credentials-safely) | Get asset detail or safe credential detail by typed reference |
66+
| [`create`](./assets.md#create-an-asset) | Create any registered built-in asset type through its type-owned configuration, or create a group |
6767
| `update` | Update an existing asset or group |
6868
| `delete` | Delete an asset or group (always asks for desktop confirmation) |
6969
| `version` | Print version information |

‎docs/guide/asset-management.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Right-click an asset and select **Delete**. Assets are soft-deleted (marked as d
162162

163163
## Credential Management
164164

165-
Managed secrets (including passwords, SSH private keys, and kubeconfigs) are encrypted with a key derived using **Argon2id** and stored using **AES-256-GCM**. OpsKat first resolves the master key from an explicit configuration, then the OS keyring, and can fall back to a protected key file in the application data directory:
165+
Sensitive connection material—including asset-local passwords and kubeconfigs, and managed password/SSH-key credentials—is encrypted with a key derived using **Argon2id** and stored using **AES-256-GCM**. OpsKat first resolves the master key from an explicit configuration, then the OS keyring, and can fall back to a protected key file in the application data directory:
166166

167167
- **macOS** — Keychain
168168
- **Windows** — Windows Credential Manager
@@ -179,6 +179,10 @@ You can import SSH private keys in two ways:
179179

180180
Imported keys are stored as credentials and can be reused across multiple assets.
181181

182+
### Automation
183+
184+
`opsctl` and the AI Agent can create registered built-in asset types, reuse compatible managed credentials, and query safe credential metadata. Plaintext passwords supplied during automated asset creation are encrypted in the asset and do not implicitly create reusable credentials. See [Asset & Credential Automation](/docs/cli/assets) for the command contract, typed references, and secret-handling boundaries.
185+
182186
## Import / Export
183187

184188
OpsKat supports importing assets from external sources and exporting your inventory for backup.

‎docs/guide/audit.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ The audit log viewer in the desktop app provides:
4848
- **Session filtering** — View all actions within a specific session
4949
- **Detail view** — Inspect the stored request and result, subject to the 4KB / 32KB audit truncation limits
5050

51+
## Audit Payload Boundaries
52+
53+
Audit payloads are raw by default: the audit writer stores the command, request, result, error, and matched pattern it receives instead of scanning their contents and replacing suspected values with `<redacted>`. Existing command canonicalization, limited output buffers, and the 4KB / 32KB truncation limits still apply, so this is not a byte-for-byte forensic transcript.
54+
55+
Some producers own a narrower write-only contract. AI/opsctl `put_asset`, desktop asset changes, and external-edit metadata write explicit allowlisted projections. For asset creation and updates, password, Secret Access Key, kubeconfig, private-key, and passphrase fields are omitted from the audit request; they do not appear as placeholder values. Safe asset and credential queries likewise return narrow metadata DTOs and never expose password, private-key, passphrase, token, kubeconfig, or SSH Agent endpoint values.
56+
57+
Direct execution and approval surfaces are different boundaries. Tool input/output, command history, errors, and approval subjects preserve the content supplied to those surfaces. Do not pass secrets in commands or arguments on the assumption that Audit or the UI will redact them. Prefer managed credential references or a command's documented standard-input secret path, such as [`opsctl create asset --password-stdin`](/docs/cli/assets#passwords-and-authentication-references).
58+
5159
## Approval Workflow
5260

5361
When the `opsctl` CLI is used while the desktop app is running, operations that require approval are routed through the app's UI.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
sidebar_position: 8
3+
sidebar_label: 资产与凭据
4+
---
5+
6+
# 资产与凭据自动化
7+
8+
`opsctl` 可以通过统一命令创建任意已注册的内建资产类型,也能发现已有托管凭据和 SSH Agent 身份,同时不返回秘密材料。
9+
10+
## 创建资产
11+
12+
```bash
13+
opsctl create asset --name <名称> [参数]
14+
```
15+
16+
用 `--type` 选择已注册的内建类型(默认是 `ssh`)。必填字段、默认值、合法组合和未知字段校验由所选类型负责。运行 `opsctl help <type>` 可查看该类型的准确配置契约。
17+
18+
类型专属配置可以直接传入 JSON 对象,也可以从文件读取:
19+
20+
```bash
21+
opsctl create asset \
22+
--type database \
23+
--name "生产数据库" \
24+
--config '{"driver":"mysql","host":"db.internal","username":"app"}' \
25+
--credential-id 4
26+
27+
opsctl create asset \
28+
--type k8s \
29+
--name "生产集群" \
30+
--kubeconfig-file ~/.kube/config \
31+
--context production
32+
```
33+
34+
`--config` 与 `--config-file` 互斥。`--host`、`--port`、`--username`、`--driver`、`--database`、`--read-only`、`--ssh-asset` 和 Kubernetes 参数等现有便捷参数仍然可用。只有显式传入的便捷参数才会覆盖通用配置中的同名非秘密值。
35+
36+
字段校验和凭据引用检查会在桌面端审批前完成;只有审批成功后才会写入资产。
37+
38+
## 密码与认证引用
39+
40+
以下秘密/引用输入彼此互斥:
41+
42+
| 输入 | 行为 |
43+
|---|---|
44+
| `--password-stdin` | 从标准输入读取明文,不显示提示也不回显;这是推荐的明文输入方式。 |
45+
| `--password <value>` | 从 argv 接收明文,并警告该值可能暴露在 Shell 历史、进程列表或 CI 日志中。 |
46+
| `--credential-id <id>` | 复用已有且类型兼容的托管密码或 SSH 密钥凭据。 |
47+
| `--agent-source-id <id>` 与 `--agent-key-fingerprint <fingerprint>` | 为 SSH Agent 认证选择已有 Agent 来源和身份。 |
48+
49+
例如:
50+
51+
```bash
52+
printf '%s\n' "$APP_PASSWORD" | \
53+
opsctl create asset --type redis --name cache \
54+
--config '{"host":"redis.internal","username":"default"}' \
55+
--password-stdin
56+
```
57+
58+
通过 `--password-stdin`、`--password` 或允许的 JSON 秘密字段传入的明文会加密到资产中,**不会**隐式创建可复用的托管凭据。请先在桌面端密钥管理器中显式创建托管密码或导入 SSH 密钥,再通过 `--credential-id` 引用。
59+
60+
不要把 SSH 私钥或 passphrase 放进自动化配置。应先在桌面端密钥管理器中导入密钥,再引用其凭据 ID。Kubernetes kubeconfig 仍直接加密在资产中。不使用密码认证的资产类型会拒绝密码输入。
61+
62+
如果 JSON 配置文件包含明文秘密,请限制文件权限、不要提交到版本库,并在不再需要时删除。
63+
64+
## 安全发现凭据
65+
66+
列出统一密钥管理清单:
67+
68+
```bash
69+
opsctl list credentials
70+
opsctl list credentials --type password
71+
opsctl list credentials --type ssh_key
72+
opsctl list credentials --type ssh_agent
73+
```
74+
75+
每项都有无歧义的类型化引用。详情查询必须使用该引用:
76+
77+
```bash
78+
opsctl get credential credential:4
79+
opsctl get credential agent-source:2
80+
```
81+
82+
凭据详情不接受裸数字 ID,因为托管凭据与 SSH Agent 来源使用不同的 ID 空间。
83+
84+
这些命令只返回身份识别和使用情况元数据。根据类型,结果可能包含名称、用户名、指纹、密钥类型/长度、清理后的备注、可用状态、引用资产,以及 SSH 密钥的公钥。它们绝不会返回密码明文或密文、SSH 私钥或 passphrase、主密钥、SSH Agent endpoint 值、签名或 challenge 秘密。
85+
86+
AI 自动化通过 `list_credentials` 和 `get_credential` 使用相同的安全发现模型,并通过 `put_asset` 使用同一资产写入边界。
87+
88+
## 审批、输出与审计
89+
90+
审批详情和成功的资产结果会省略 write-only 秘密。`put_asset` 审计 producer 同样写入字段白名单投影:password、Secret Access Key、kubeconfig、私钥和 passphrase 字段会直接不存在,而不是替换成 `<redacted>`。
91+
92+
该资产写入专用投影不代表所有审计记录。其他已审计工具会保存审计 writer 实际收到的 command、request、result 和 error,同时继续受既有 canonical command、limited buffer 与截断规则约束。参见[审计与审批](../guide/audit.md#审计载荷边界)。

‎i18n/zh-CN/docusaurus-plugin-content-docs/current/cli/overview.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ OpsKat 桌面应用运行时,`opsctl` 会通过本地套接字连接应用:
6161
| [`ext`](./ext.md) | 列出已安装扩展或执行扩展工具 |
6262
| `help` | 查看 CLI 用法,或用 `opsctl help <asset>` 查看该资产类型的命令语法 |
6363
| `session` | 管理审批会话(start、end、status) |
64-
| `list` | 列出资源(`assets` 或 `groups`) |
65-
| `get` | 获取资源详情 |
66-
| `create` | 创建受支持的 SSH、数据库、Redis、MongoDB 或 Kubernetes 资产,或创建分组 |
64+
| [`list`](./assets.md#安全发现凭据) | 列出资产、分组或安全凭据元数据 |
65+
| [`get`](./assets.md#安全发现凭据) | 获取资产详情,或通过类型化引用获取安全凭据详情 |
66+
| [`create`](./assets.md#创建资产) | 通过类型自有配置创建任意已注册的内建资产类型,或创建分组 |
6767
| `update` | 更新已有资产或分组 |
6868
| `delete` | 删除资产或分组(始终需要桌面端确认) |
6969
| `version` | 输出版本信息 |

‎i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/asset-management.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ VNC 资产通过 [VNC 客户端](/docs/guide/vnc)打开内嵌的 RFB 远程桌
162162

163163
## 凭据管理
164164

165-
托管的敏感信息(包括密码、SSH 私钥和 kubeconfig)会使用 **Argon2id** 派生密钥,并通过 **AES-256-GCM** 加密存储。OpsKat 先从显式配置解析主密钥,再尝试操作系统 keyring,最后可回退到应用数据目录中受保护的密钥文件:
165+
敏感连接材料——包括资产内联的密码和 kubeconfig,以及托管的密码/SSH 密钥凭据——会使用 **Argon2id** 派生密钥,并通过 **AES-256-GCM** 加密存储。OpsKat 先从显式配置解析主密钥,再尝试操作系统 keyring,最后可回退到应用数据目录中受保护的密钥文件:
166166

167167
- **macOS** — Keychain
168168
- **Windows** — Windows Credential Manager(Windows 凭据管理器)
@@ -179,6 +179,10 @@ VNC 资产通过 [VNC 客户端](/docs/guide/vnc)打开内嵌的 RFB 远程桌
179179

180180
导入的密钥作为凭据存储,可以在多个资产之间复用。
181181

182+
### 自动化
183+
184+
`opsctl` 与 AI 智能体可以创建已注册的内建资产类型、复用兼容的托管凭据并查询安全凭据元数据。自动创建资产时传入的明文密码会加密到资产中,不会隐式创建可复用凭据。命令契约、类型化引用与秘密处理边界参见[资产与凭据自动化](/docs/cli/assets)。
185+
182186
## 导入 / 导出
183187

184188
OpsKat 支持从外部来源导入资产,也支持导出资产清单用于备份。

‎i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/audit.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ OpsKat 会记录 AI 与 `opsctl` 的工具执行,包括来源、结果以及
4848
- **会话筛选** — 查看特定会话中的所有操作
4949
- **详情视图** — 查看已存储的请求和结果,受 4KB / 32KB 审计截断上限约束
5050

51+
## 审计载荷边界
52+
53+
审计载荷默认保留原值:审计 writer 会保存其实际收到的 command、request、result、error 和 matched pattern,不会扫描内容并把疑似秘密替换为 `<redacted>`。既有的命令 canonicalization、有限输出缓冲区以及 4KB / 32KB 截断上限仍然生效,因此这不是逐字节的取证记录。
54+
55+
部分 producer 拥有更窄的 write-only 契约。AI/opsctl `put_asset`、桌面资产变更和 external-edit 元数据会写入显式字段白名单投影。创建或更新资产时,password、Secret Access Key、kubeconfig、私钥和 passphrase 字段会从审计请求中省略,而不是显示为占位值。安全资产/凭据查询同样只返回窄元数据 DTO,绝不会暴露密码、私钥、passphrase、token、kubeconfig 或 SSH Agent endpoint 值。
56+
57+
直接执行与审批表面属于不同边界:工具输入/输出、命令历史、错误和审批主体会保留传入这些表面的内容。不要假设 Audit 或 UI 会替你脱敏,从而把秘密写入命令或参数。应优先使用托管凭据引用,或命令明确提供的标准输入秘密通道,例如 [`opsctl create asset --password-stdin`](/docs/cli/assets#密码与认证引用)。
58+
5159
## 审批工作流
5260

5361
当 `opsctl` CLI 在桌面应用运行期间使用时,需要审批的操作会被路由到应用的 UI 界面。

0 commit comments

Comments
 (0)