fix(aiops): Agent CLI 连接 ssh-key 主机永久转圈修复
- buildSSHConfig 放宽认证判定:SSHKey 非空即走密钥认证,不再强依赖 AuthType=="key", 兼容编辑表单/历史数据未正确设置 AuthType 的 ssh-key 主机(与 WebShell 行为对齐) - agent_cli WS 握手:Upgrade 提前到预检之前,预检失败经 writeWSCloseError 推具体 error 帧;写 error 后 sleep 120ms 再发 close,避免 TCP 提前关闭导致 error 帧丢失 - 前端 AgentCLI 连接兜底:新增 8s 连接超时 + onclose 区分"从未连上"(push 明确 原因提示)与"连上后断开",杜绝预检失败时"正在连接主机"永久转圈、看不到原因 - 引擎配置补传 ReasoningEnabled Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
01967bc52b
commit
3b19ae6e98
3 files changed
+73
-25
No files matched your search
@@ -289,10 +289,15 @@ func buildSSHConfig(db *gorm.DB, server model.Server) (remoteexec.SSHConfig, err
|
||||
cfg.User = "root"
|
||||
}
|
||||
|
||||
// 优先使用 server 自带的认证信息
|
||||
if server.AuthType == "key" && server.SSHKey != "" {
|
||||
// 优先 SSH 密钥:只要 server.SSHKey 有值就用密钥认证,不依赖 AuthType 严格等于 "key",
|
||||
// 兼容历史数据/编辑表单未正确设置 AuthType 的 ssh-key 主机(与 WebShell 行为对齐)// Logan.Li
|
||||
if server.SSHKey != "" {
|
||||
cfg.AuthType = remoteexec.AuthKey
|
||||
cfg.KeyData = server.SSHKey
|
||||
// 同时带上 password 作为兜底:remoteexec 在密钥解析失败时会回退用密码
|
||||
if server.Password != "" {
|
||||
cfg.Password = server.Password
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
if server.Password != "" {
|
||||
@@ -301,11 +306,7 @@ func buildSSHConfig(db *gorm.DB, server model.Server) (remoteexec.SSHConfig, err
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
// 从凭证表查找关联的 SSH 凭据
|
||||
// Server 模型目前没有 CredentialID 字段,通过 tags 或 name 匹配
|
||||
// 未来可扩展 server.credential_id FK
|
||||
|
||||
return cfg, fmt.Errorf("服务器 %s 未配置 SSH 认证(密码或密钥)", server.Hostname)
|
||||
return cfg, fmt.Errorf("服务器 %s 未配置 SSH 认证(密码或密钥),请到服务器详情关联 SSH 凭据", server.Hostname)
|
||||
}
|
||||
|
||||
// ==================== 定时任务远程执行(对接 CronJob target_type) ====================
|
||||
|
||||
Reference in new issue
Block a user