Jenkins源码管理git报错:Host key verification failed

Failed to connect to repository : Command "git ls-remote -h git@ip:xxx.git HEAD" returned status code 128:
stdout:
stderr: Host key verification failed.

这需要使用jenkins用户访问该git服务器添加到~/.ssh/known_hosts。
1.切换为jenkins用户:

sudo su -s /bin/bash jenkins

2.执行git命令:

git ls-remote -h git@ip:xxx.git HEAD

在终端提示如下:

The authenticity of host 'ip (xxx.xxx.xxx.xx)' can't be established.
RSA key fingerprint is 84:8c:14:f2:6f:14:6d:6c:3b:fc:ac:49:a6:7c:7a:41.
Are you sure you want to continue connecting (yes/no)?

输入yes回车。这时,ip就已经添加到~/.ssh/known_hosts。

你可能感兴趣的:(Jenkins源码管理git报错:Host key verification failed)