1

我在 openshift 上有詹金斯。我可以进行以下操作,并且可以。

[jenkins-<USER>.rhcloud.com data]\> ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /var/lib/openshift/<NUMBERED DIRECTORY>/app-root/data/.ssh/jenkins_id_rsa git@github.com
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi <USER>! You've successfully authenticated, but GitHub does not provide shell access.
          Connection to github.com closed.

所以它确实连接到 github ......即使我从 shell 克隆了它。

但是,当我尝试将 repo 添加到 jenkins 作业时,它会出现以下错误。它是一个私人回购。

Failed to connect to repository : Command "git ls-remote -h git@github.com:<USER>/test.git HEAD" returned status code 128:
stdout:
stderr: Host key verification failed.
fatal: The remote end hung up unexpectedly
4

1 回答 1

1

Jenkins 可能正在运行,jenkins并且您接受了主机密钥,因为<USER>您可以通过将命令添加whoami到构建步骤来确认这一点,并确认用户jenkins与 shell 中的用户不同。

一种解决方案是登录jenkins并接受 github 的密钥。

另一种是从github的~/.ssh/known_hosts中复制这行,复制到jenkins文件夹~jenkins/.ssh/known_hosts中的known_hosts中。

于 2013-03-14T15:38:03.477 回答