问题
在项目中配置git仓库地址时,报无权限:
Failed to connect to repository : Command "git ls-remote -h git@xxx.git HEAD" returned status code 128:
stdout:
stderr: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rightsand the repository exists.
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6ioBZZZV-1586504276353)(evernotecid://B1C45E84-DAD5-4A3E-8F09-F042CE8BEC59/appyinxiangcom/9699651/ENResource/p2458)]](/https://i-blog.csdnimg.cn/blog_migrate/73f59e6ec2dd477f43a5fa3392a2fc7a.png)
原因
密钥验证失败,导致无法从远程仓库读取。请确保您有正确的访问权限和git仓库的存在。
解决方案
1、部署jenkins的机器创建密钥文件。
执行:
ssh-keygen -t rsa -C "xxxx@xx.com"
随后即可查看到密钥文件
-bash-4.2# pwd
/root/.ssh
-bash-4.2# ls
authorized_keys id_rsa id_rsa.pub known_hosts
2、将公钥id_rsa.pub配置在git仓库的拥有者的账号上。
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-f1K3Pmsq-1586504276354)(evernotecid://B1C45E84-DAD5-4A3E-8F09-F042CE8BEC59/appyinxiangcom/9699651/ENResource/p2462)]](/https://i-blog.csdnimg.cn/blog_migrate/f65cf4e9472d52fe6d0128d12a6f6d7e.png)
3、在"jenkins --> 凭据 --> 系统 --> 全局凭据"中添加一个SSH凭据,配置生成的私钥id_rsa。
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6IaNlxsb-1586504276355)(evernotecid://B1C45E84-DAD5-4A3E-8F09-F042CE8BEC59/appyinxiangcom/9699651/ENResource/p2464)]](/https://i-blog.csdnimg.cn/blog_migrate/628541c07e1be13fded232107d02f142.png)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jwD8JPti-1586504276355)(evernotecid://B1C45E84-DAD5-4A3E-8F09-F042CE8BEC59/appyinxiangcom/9699651/ENResource/p2465)]](/https://i-blog.csdnimg.cn/blog_migrate/a7a10cbe364dd4eb65e732c3f006d4db.png)
4、然后在项目中就可以使用git账号拉取远程仓库的数据了。

配置Jenkins连接gitlab仓库时遇到status code 128错误,原因是密钥验证失败。解决步骤包括在jenkins服务器创建密钥文件,将公钥添加到git仓库账号,将私钥配置到Jenkins全局凭据,并在项目中使用该凭据拉取仓库数据。

679

被折叠的 条评论
为什么被折叠?



