Jenkins连接gitlab报错:returned status code 128

逃离我推掉我的手 2023-07-24 08:56 231阅读 0赞

文章目录

    • 问题
    • 原因
    • 解决方案

问题

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

  1. Failed to connect to repository : Command "git ls-remote -h git@xxx.git HEAD" returned status code 128:
  2. stdout:
  3. stderr: Host key verification failed.
  4. fatal: Could not read from remote repository.
  5. 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的机器创建密钥文件。
执行:

  1. ssh-keygen -t rsa -C "xxxx@xx.com"

随后即可查看到密钥文件

  1. -bash-4.2# pwd
  2. /root/.ssh
  3. -bash-4.2# ls
  4. 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账号拉取远程仓库的数据了。
在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,231人围观)

还没有评论,来说两句吧...

相关阅读