Jenkins使用github返回状态码128

niz*_*ghi 64 github jenkins

用github命令我有

ssh -T git@github.com
Hi (MyName)! You've successfully authenticated, but GitHub does not provide shell access.
Run Code Online (Sandbox Code Playgroud)

我与github的连接没问题,但是对于jenkins我有这个错误

ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:Name-MysRepo/MyRepo.git
hudson.plugins.git.GitException: Could not clone git@github.com:Name-MysRepo/MyRepo.git
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clone(CliGitAPIImpl.java:219)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1001)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:942)
    at hudson.FilePath.act(FilePath.java:904)
    at hudson.FilePath.act(FilePath.java:877)
    at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:942)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1369)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
    at hudson.model.Run.execute(Run.java:1575)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:241)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git@github.com:Name-MysRepo/MyRepo.git /root/.jenkins/jobs/TestKRGDAOV01/workspace" returned status code 128:
stdout: Cloning into '/root/.jenkins/jobs/TestKRGDAOV01/workspace'...

stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

为什么这个问题与publickey我在TomCat7/ubuntu 12下使用jenkins请帮忙

imd*_*iji 48

这个错误:

stderr:权限被拒绝(publickey).致命:远程端意外挂断

表示Jenkins正在尝试使用错误的ssh密钥连接到github.

你应该:

  1. 确定jenkins运行的用户,例如.'build'或'jenkins'
  2. 登录尝试进行克隆的jenkins主机 - 也就是说,如果节点实际正在进行构建,则不要登录到主服务器.
  3. 尝试使用ssh到github - 如果失败,则需要将正确的密钥添加到/.ssh


Tim*_*ong 13

要检查以下内容:

  1. 如果正确的公钥(id_rsa.pub)上传到git-server.
  2. 如果右私钥(id_rsa)被复制到/var/lib/jenkins/.ssh/
  3. 如果在〜/ .ssh文件夹中创建了known_hosts文件.尝试ssh -vvv git@github.com查看调试日志.如果事情进展顺利,github.com将被添加到known_hosts.
  4. 如果id_rsa的权限设置为700(chmod 700 id_rsa)

检查完毕后,试试吧ssh -vvv git@github.com.


Rob*_*rto 8

还要确保您使用的是 ssh github url 而不是 https

  • @starscream_disco_party我明白,这与为什么http在轮询时超时有什么关系 (2认同)

小智 5

在我的情况下,我必须将公钥添加到我的存储库(在 Bitbucket)中,并通过 ssh 使用一次 git clone 来第一次对“已知主机”问题回答“是”。