傲渊山岳 发表于 2024-11-4 19:20:00

Jenkins构建流水线SSH毗连Git错误:Host key verification failed 报错题目

报错信息:

   无法毗连仓库: Command "git ls-remote -h -- git@ip:xxx/xxx.git HEAD"
returned status code 128:
stdout:
stderr: No ED25519 host key is known for <ip> and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rightsand the repository exists.
题目表明:

主要是因为主秘密钥验证的题目
解决方法:

方法一:

 打开jenkins系统配置中的全局配置
https://i-blog.csdnimg.cn/blog_migrate/0eb16ab5585e50b69f105747ce0838d6.png
将Git Host Key Verification Configuration中的Host Key Verification Strategy改为No verification
https://i-blog.csdnimg.cn/blog_migrate/be17a0b64fd23f8c8b2b55f458a94bfa.png
生存即可
这是通过将主秘密钥验证战略改成不用证书验证的模式(注意:在考虑安全性的情况下不要使用这种方法)
方法二:

通过在jenkins服务器上配置主秘密钥验证
步骤:

通过ssh-keyscan生成gitlab服务器的主秘密钥验证,并将这个文件写入jenkins配置文件中的known_hosts验证文件里,已达到验证某个主秘密钥验证
jenkins摆设在服务器上
sudo -u jenkins ssh-keyscan -H <Gitlab服务器ip> >> /var/lib/jenkins/.ssh/known_hosts
jenkins是通过docker启动:
sudo docker exec -u jenkins <jenkins_container_name> ssh-keyscan -H <Gitlab服务器ip> >> /var/jenkins_home/.ssh/known_hosts

 

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: Jenkins构建流水线SSH毗连Git错误:Host key verification failed 报错题目