https://majing.io/posts/10000007031172
在jenkins集成给it,执行git命令测试如下:
git ls-remote -h username@mygit.com:username/myproject.git HEAD
报错如下:
Failed to connect to repository : Command "git ls-remote -h username@mygit.com:cc/myproject.git HEAD" returned status code 128: stdout: stderr: Host key verification failed. fatal: The remote end hung up unexpectedly
原因
这需要使用jenkins用户访问mygti.com的主机添加到~/.ssh/known_hosts。
解决
切换为jenkins用户:
sudo su -s /bin/bash jenkins
在jenkins用户下执行刚才的git命令:
git ls-remote -h username@mygit.com:username/myproject.git HEAD
在终端提示如下:
The authenticity of host 'mygit.com (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回车。这时,mygit.com就已经添加到~/.ssh/known_hosts。