【发布时间】:2012-04-17 20:44:02
【问题描述】:
我刚刚设置了我的第一个 Jenkins 从站。我运行构建,但遇到了 SSH 密钥问题。 主 Jenkins 服务器在用户“jenkins”下运行。我已经设置了 SSH 密钥,这样我就可以在没有密码的情况下从主机 SSH 到从机。
例如来自主人:
jenkins@master:~$ ssh slave
Last login: Tue Apr 17 10:30:22 2012 from masterjenkins.com
$ whoami
jenkins
这样证明slave节点也在'jenkins'用户下运行。 (我已将公共 ssh 密钥从 jenkins@slave 复制到远程 git 服务器)。而且我可以从从站手动发出 git clone,但是当我从主站开始构建时,我会收到以下类型的消息:
ERROR: Error cloning remote repo 'origin' : Could not clone git@host:abc
hudson.plugins.git.GitException: Could not clone git@host:abc
Caused by: hudson.plugins.git.GitException: Error performing command: git clone --progress -o origin git@host:abc /var/lib/jenkins/workspace/abc_build
Command "git clone --progress -o origin git@host:abc /var/lib/jenkins/workspace/abc_build" returned status code 128: Initialized empty Git repository in /var/lib/jenkins/workspace/abc_build/.git/
Host key verification failed.
fatal: The remote end hung up unexpectedly
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git@host:abc /var/lib/jenkins/workspace/abc_build" returned status code 128: Initialized empty Git repository in /var/lib/jenkins/workspace/abc_build/.git/
Host key verification failed.
fatal: The remote end hung up unexpectedly
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
所以它仍然暗示我的 SSH 密钥设置不正确。 谁能告诉我需要将哪些密钥复制到哪里?
非常感谢, ns
【问题讨论】:
-
主机密钥验证失败似乎表明您的 Jenkins 用户从未 ssh 进入该服务器并且您尚未接受主机密钥,请尝试以 jenkins 用户身份从 CLI 进行 ssh 以确保它可以工作,并接受主机密钥。
-
@Doon 这可能最终成为问题。我原本以为你正试图从 Jenkins 试图克隆的同一台机器上进行 ssh。
-
搞定这个混蛋!感谢您的输入。我复制并粘贴了 jenkins 试图在从属设备上运行的命令: git clone --progress -o origin git@host:abc /var/lib/jenkins/workspace/abc 事实证明我在 /root 中有一些违规键/.ssh/known_hosts 删除这些并再次连接到 git repo 后,它工作了!
标签: git ssh hudson jenkins slave