jenkins-git-clone报错问题解决

No RSA host key is known for

1
2
3
4
5
Failed to connect to repository : Command "D:\Program Files\Git\bin\git.exe ls-remote -h -- git@codeup.aliyun.com: HEAD" returned status code 128:
stdout:
stderr: No RSA host key is known for codeup.aliyun.com and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

🥇 方案一:修改 Jenkins 全局安全配置(最快捷)

Jenkins 的 Git 主机密钥验证策略需要在 全局设置中配置,无法针对单个任务调整。

  1. 使用管理员账户登录 Jenkins。
  2. 进入 Manage Jenkins -> Security(系统管理 -> 全局安全配置)。
  3. 找到 Git Host Key Verification Configuration 区域。
  4. 将 Host Key Verification Strategy 修改为 Accept first connection(接受首次连接)或 No verification(不验证)。
    • Accept first connection:允许连接并在首次连接后自动记录主机密钥,兼顾便利与安全。
    • No verification:完全禁用主机密钥验证,安全性最低,仅建议在完全可控的内网测试环境中使用。
  5. 保存配置后,重新触发 Jenkins 任务。

error: external filter ‘git-lfs filter-process’ failed

Jenkins用户路径:C:\Windows\System32\config\systemprofile\.ssh

方案二:为 Jenkins 用户显式配置 SSH 密钥

如果必须使用 SYSTEM 账户运行,需手动为它配置密钥:

  1. 找到 Jenkins 服务的运行账户(默认为 SYSTEM)。
  2. 为这个账户创建 .ssh 目录(例如 C:\Windows\System32\config\systemprofile\.ssh)。
  3. 将你的私钥(id_rsa)和公钥(id_rsa.pub)复制到该目录。
  4. 确保 id_rsa 文件权限正确,只有运行账户可读。

更规范的做法是使用 “SSH Username with private key” 类型的 Jenkins 凭据,让 Git 插件在检出时自动注入密钥

归档 GitHub