报错内容
无法连接仓库:Command "git ls-remote -h -- [email protected]:gitlab-instance-edd44d36/music.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 rights
and the repository exists.
解决思路
原因:可能是用jenkins用户启动的 jenkins
[root@jenkins ~]# ps aux |grep jenkins
jenkins 8092 4.8 33.5 4811200 1273496 ? Ssl 00:59 1:11 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
root 8732 0.0 0.0 12140 1164 pts/0 S+ 01:23 0:00 grep --color=auto jenkins
那么我们需要将jenkins用户的key放到gitlab上
#生成key
[jenkins@jenkins ~]$ ssh-keygen
[jenkins@jenkins ~]$ cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaCYg...省略... [email protected]
注意:jenkins用户做完key验证后仍需手动执行一次git clone
原因是因为要输入一次 "yes",否则就会出现上面错误
[jenkins@jenkins ~]$ git clone [email protected]:gitlab-instance-edd44d36/music.git
Cloning into 'music'...
The authenticity of host 'gitlab.willoneday.com (10.0.0.17)' can't be established.
ECDSA key fingerprint is SHA256:eIFOBEiKfy/IyPN/WrsB7MA8WQYLogOZ0+dZJtROcEE.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
建议
使用root用户启动 jenkins
jenkins默认是以jenkins用户启动的。
但jenkins 在构建工程时,默认的权限是不够写入文件的。这时就需要把它的权限提升为root。
#修改下面两行
[root@jenkins ~]# vim /usr/lib/systemd/system/jenkins.service
User=root
Group=root
#重启jenkins
[root@jenkins ~]# systemctl daemon-reload
[root@jenkins ~]# systemctl restart jenkins.service
标签:gitlab,git,Gitlab,willoneday,报错,key,jenkins,root From: https://www.cnblogs.com/Willoneday/p/17081281.html