Jenkins连接gitlab报错:returned status code 128
文章目录
- 问题
- 原因
- 解决方案
问题
在项目中配置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.
原因
密钥验证失败,导致无法从远程仓库读取。请确保您有正确的访问权限和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仓库的拥有者的账号上。
3、在”jenkins —> 凭据 —> 系统 —> 全局凭据”中添加一个SSH凭据,配置生成的私钥id_rsa。
4、然后在项目中就可以使用git账号拉取远程仓库的数据了。
还没有评论,来说两句吧...