Skip to content

Commit fccf9ea

Browse files
committed
docs(quick-260405-qk2): SSH密钥体系改造
1 parent 8b994dc commit fccf9ea

3 files changed

Lines changed: 72 additions & 2 deletions

File tree

.planning/STATE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ None.
7979
| 260405-hai | 增强 Claude 状态 API:返回每个进程的 PID、工作目录和运行时间 | 2026-04-05 | 2ae9592 | [260405-hai-claude-api-pid](./quick/260405-hai-claude-api-pid/) |
8080
| 260405-hio | Claude Code 深度配置集成:结构化settings编辑面板+系统指纹查看 | 2026-04-05 | bea7886 | [260405-hio-claude-code-settings](./quick/260405-hio-claude-code-settings/) |
8181
| 260405-jji | 镜像版本管理:自动拉取最新镜像+版本展示+一键升级 | 2026-04-05 | 6aad37a | [260405-jji-image-version-mgmt](./quick/260405-jji-image-version-mgmt/) |
82+
| 260405-qk2 | SSH密钥体系改造:入站免密登录+出站外部鉴权+多密钥管理 | 2026-04-05 | d297fbb | [260405-qk2-ssh](./quick/260405-qk2-ssh/) |
8283

8384
## Session Continuity
8485

85-
Last session: 2026-04-05T06:10:00.000Z
86-
Stopped at: Completed 260405-jji quick task
86+
Last session: 2026-04-05T11:15:00.000Z
87+
Stopped at: Completed 260405-qk2 SSH 密钥体系改造
8788
Resume file: None
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Quick Task 260405-qk2: SSH 密钥体系改造
2+
3+
**Created:** 2026-04-05
4+
**Status:** Completed
5+
6+
## Goal
7+
8+
将 SSH 密钥系统从单密钥对改造为多密钥管理,拆分为入站(免密登录)和出站(外部服务鉴权)两类用途。
9+
10+
## Tasks
11+
12+
### Task 1: 数据库 + 后端模型
13+
- 新建 `ssh_keys` 表(migration 0012),包含 purpose、label、fingerprint 等字段
14+
-`users` 表自动迁移已有密钥数据
15+
- 添加 SSHKey 模型和 5 个 Repository 方法
16+
17+
### Task 2: 后端 API + 注入逻辑
18+
- 重写 ssh_keys.go 为 List/Create/Delete 三端点
19+
- contracts.go 添加 SSHKeyEntry,HostActionRequest 支持密钥数组
20+
- runtime_service.go 查询所有密钥并传递
21+
- worker.go 入站密钥→authorized_keys,出站密钥→身份文件
22+
- router.go 更新路由
23+
24+
### Task 3: 前端
25+
- 重写 hooks 为多密钥 CRUD
26+
- 重写 SSHKeyManager 分为入站/出站两个区域
27+
- 更新用户详情页和门户页
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Quick Task 260405-qk2: SSH 密钥体系改造 — Summary
2+
3+
**Completed:** 2026-04-05
4+
5+
## 变更概要
6+
7+
### 问题
8+
原有 SSH 密钥系统每用户仅支持一对密钥,存储在 users 表上,无法区分入站(免密登录)和出站(外部鉴权)用途,也不支持写入 authorized_keys。
9+
10+
### 解决方案
11+
12+
#### 数据库
13+
- 新建 `ssh_keys` 表,支持多密钥、`purpose` 字段(inbound/outbound)、label、fingerprint
14+
- 自动从 users 表迁移已有密钥数据
15+
16+
#### 后端
17+
- `contracts.go`: 新增 `SSHKeyEntry` 类型,`HostActionRequest` 新增 `SSHKeys` 数组字段
18+
- `ssh_keys.go`: 完全重写为 List/Create/Delete 三端点,Create 支持自动生成密钥对(outbound)或直接导入公钥(inbound)
19+
- `runtime_service.go`: 从新表查询用户所有密钥并传递到 HostActionRequest
20+
- `worker.go`: 入站密钥追加到 `~/.ssh/authorized_keys`,出站密钥注入为身份文件(第一个用默认名,后续用 label 命名)
21+
- `router.go`: 更新 admin 和 user 路由
22+
23+
#### 前端
24+
- `use-ssh-keys.ts`: 重写为多密钥 CRUD hooks
25+
- `ssh-key-manager.tsx`: 重新设计为入站/出站两个独立区域,入站仅需粘贴公钥,出站支持生成和导入
26+
- 用户详情页和门户页同步更新
27+
- 引导组件更新描述文字
28+
29+
## 修改的文件(13 个)
30+
- `internal/store/migrations/0012_ssh_keys_table.sql` — 新建
31+
- `internal/store/repository/models.go` — SSHKey 模型
32+
- `internal/store/repository/queries.go` — 5 个 CRUD 方法
33+
- `internal/agentapi/contracts.go` — SSHKeyEntry + SSHKeys 字段
34+
- `internal/controlplane/http/ssh_keys.go` — 完全重写
35+
- `internal/controlplane/http/router.go` — 路由更新
36+
- `internal/runtime/runtime_service.go` — 密钥查询和传递
37+
- `internal/runtime/tasks/worker.go` — injectSSHKeys 重写
38+
- `web/admin/src/hooks/use-ssh-keys.ts` — 完全重写
39+
- `web/admin/src/components/ssh-keys/ssh-key-manager.tsx` — 完全重写
40+
- `web/admin/src/routes/_dashboard/users/$userId.tsx` — 适配新接口
41+
- `web/admin/src/routes/_portal/portal/hosts/$hostId.tsx` — 适配新接口
42+
- `web/admin/src/components/onboarding-guide.tsx` — 更新引导文字

0 commit comments

Comments
 (0)