jenkins/hudson无法连接到github repo

Chr*_*abe 21 git hudson github jenkins

我在Ec2上使用基础amazon ami linux-我已经安装了jenkins但是当我从github拉回购时我发出以下错误:

Building in workspace /var/lib/jenkins/workspace/build social
Checkout:build social / /var/lib/jenkins/workspace/build social - hudson.remoting.LocalChannel@5c7b21b
Using strategy: Default
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:adulion/.git
hudson.plugins.git.GitException: Could not clone git@github.com:adulion/.git
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:245)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1117)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1059)
    at hudson.FilePath.act(FilePath.java:832)
    at hudson.FilePath.act(FilePath.java:814)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1059)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1218)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:581)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:470)
    at hudson.model.Run.run(Run.java:1421)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:238)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git@github.com:adulion/.git /var/lib/jenkins/workspace/build social" returned status code 128:
stdout: Cloning into /var/lib/jenkins/workspace/build social...

stderr: Host key verification failed.
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

我已经为安装了jenkins的当前用户生成了一个密钥,并且已经设法使用git命令行克隆了repo,但是jenkins却没有.

我已将〜/ .ssh文件复制到/var/lib/jenkins/.ssh中

我已经将github添加到已知主机中,并且我已经用尽了解决方案.谁知道我哪里错了?有没有办法让jenkins显示它正在使用的公钥,我可以调试它是否使用正确的公钥?

我删除了回购的名称,因为它是一个私人回购

sti*_*sti 29

错误似乎是:主机密钥验证失败.

您应该以Jenkins用户身份登录Jenkins主机并运行:

ssh git@github.com
Run Code Online (Sandbox Code Playgroud)

然后对有关主机密钥的提示回答"是".这只需要做一次.

或者你可以在~jenkins/.ssh/config中添加"StrictHostKeyChecking no".

  • `ssh git @ github.com`没有提示主机密钥,而是在通道0/Hi $ {NAME}上回显_PTY分配请求失败!您已成功通过身份验证,但GitHub不提供shell访问权限.然而,`StrictHostKeyChecking no`就像一个魅力. (2认同)

gre*_*reg 6

1) 将用户切换到您的 jenkins 帐户

su jenkins
Run Code Online (Sandbox Code Playgroud)

2)创建没有密码的密钥

3) ssh git@github.com

这对我来说非常有效。

您可能需要为 jenkins 帐户创建密码,如果是这样,请使用 sudo passwd jenkins


mpd*_*rty 5

我正在使用单个jenkins机器检查多个github存储库,并在设置时遇到类似问题.我最终做的是为jenkins配置SSH配置文件,以便SSH自动知道与每个存储库关联的id文件.

/var/lib/jenkins/.ssh/config:

Host github-ABC
  HostName github.com
  User git
  IdentityFile /var/lib/jenkins/.ssh/id_rsa_ABC
Run Code Online (Sandbox Code Playgroud)

在源代码管理下的Jenkins项目配置中,我使用它作为存储库名称:

git@github-ABC:user/repo.git
Run Code Online (Sandbox Code Playgroud)

最后,我使用SSH公钥作为github存储库中的部署密钥.


Max*_*Max 5

他跟随帮助我:

在Jenkins下登录

sudo su jenkins
Run Code Online (Sandbox Code Playgroud)

将您的github密钥复制到Jenkins .ssh文件夹

cp ~/.ssh/id_rsa_github* /var/lib/jenkins/.ssh/
Run Code Online (Sandbox Code Playgroud)

拉上钥匙

mv id_rsa_github id_rsa
mv id_rsa_github.pub id_rsa.pub
Run Code Online (Sandbox Code Playgroud)