【问题标题】:Jenkins finds cannot find ssh key [closed]詹金斯发现找不到 ssh 密钥 [关闭]
【发布时间】:2012-08-23 18:34:11
【问题描述】:

当我以 jenkins 用户身份登录时,我在 ~/.ssh/id_rsa.pub 中有一个 ssh 密钥。

我已将其正确导入 bitbucket,并且它已接受密钥。

当我尝试执行 git clone(到正确的 URL)时,我仍然得到......

Building in workspace /var/lib/jenkins/jobs/Google adwords/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Google adwords/workspace - hudson.remoting.LocalChannel@2c473996
Using strategy: Default
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone git@bitbucket.org:DAVID99WORLD/assessme.git
hudson.plugins.git.GitException: Could not clone git@bitbucket.org:DAVID99WORLD/assessme.git
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:268)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1122)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064)
    at hudson.FilePath.act(FilePath.java:842)
    at hudson.FilePath.act(FilePath.java:824)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1064)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1256)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494)
    at hudson.model.Run.execute(Run.java:1502)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:236)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git@bitbucket.org:DAVID99WORLD/assessme.git /var/lib/jenkins/jobs/Google adwords/workspace" returned status code 128:
stdout: Cloning into '/var/lib/jenkins/jobs/Google adwords/workspace'...

stderr: Host key verification failed.
fatal: The remote end hung up unexpectedly

有人知道为什么会发生这种情况吗?根据我读过的文档, ~/.ssh 是该文件存在的 jenkins 用户的正确目录。

编辑:我的 jenkins 用户在 ~/.ssh 中没有 known_hosts 文件,但我的根级用户有 - 应该吗?我可以很好地与我的 jenkins 用户进行克隆,并且它根本没有提及作为 jenkins 用户的主机。

【问题讨论】:

  • 删除了我的答案,应该是评论。确保 jenkins 实际上是作为 jenkins 运行的。您使用的是 Winstone servlet 还是其他东西——比如 Tomcat?
  • SO 题外话;属于Server FaultSuper User

标签: java git ubuntu bitbucket


【解决方案1】:

它可能与 known_hosts 文件无关。我认为,您必须检查 Jenkins 是否能够读取您的公共 SSH 密钥。因此,您可能需要检查:

  • 在 /etc/passwd 中为 Jenkins 用户定义的主页与 ~/.ssh 匹配
  • Jenkins 用户可以访问他的主目录(因此在上述所有目录中至少 --x--x--x)
  • Jenkins 用户可以访问 id_rsa.pub 文件
  • Jenkins 实际上是与 Jenkins 用户一起运行,而不是例如Tomcat用户

另外,如果您删除当前的 id_rsa.pub 文件会怎样?它是否抱怨找不到要使用的公钥?

【讨论】:

  • 你能写出我们需要运行的macosx命令来执行这个操作吗?我有完全相同的问题。我真的很喜欢它stackoverflow.com/questions/13267964/…
  • @Claus 这很难做到,因为它在很大程度上取决于服务器配置。
猜你喜欢
  • 1970-01-01
  • 2016-09-16
  • 2012-09-30
  • 2014-07-24
  • 2018-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多