Jenkins连接gitlab报错:returned status code 128

文章目录

问题

在项目中配置git仓库地址时,报无权限:

Failed to connect to repository : Command "git ls-remote -h [email protected] 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)]

原因

密钥验证失败,导致无法从远程仓库读取。请确保您有正确的访问权限和git仓库的存在。

解决方案

1、部署jenkins的机器创建密钥文件。
执行:

ssh-keygen -t rsa -C "[email protected]" 

随后即可查看到密钥文件

-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)]

3、在"jenkins --> 凭据 --> 系统 --> 全局凭据"中添加一个SSH凭据,配置生成的私钥id_rsa。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6IaNlxsb-1586504276355)(evernotecid://B1C45E84-DAD5-4A3E-8F09-F042CE8BEC59/appyinxiangcom/9699651/ENResource/p2464)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jwD8JPti-1586504276355)(evernotecid://B1C45E84-DAD5-4A3E-8F09-F042CE8BEC59/appyinxiangcom/9699651/ENResource/p2465)]
4、然后在项目中就可以使用git账号拉取远程仓库的数据了。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/tt75281920/article/details/105434989