詹金斯发现无法找到ssh密钥 [英] Jenkins finds cannot find ssh key

查看:210
本文介绍了詹金斯发现无法找到ssh密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经正确导入到bitbucket中了。

我在〜/ .ssh / id_rsa.pub中有一个ssh密钥,当我以jenkins用户身份登录时。并且它已经接受了这个键。



当我尝试做一个git clone(到正确的URL)时,我仍然得到....

 在工作区中构建/ var / lib / jenkins / jobs / Google adwords / workspace 
签出:工作区/ var / lib / jenkins / jobs / Google adwords / workspace - hudson.remoting.LocalChannel@2c473996
使用策略:默认
克隆远程Git存储库
克隆存储库源
错误:克隆远程回购源错误:无法克隆git@bitbucket.org:DAVID99WORLD / assessme.git
hudson.plugins.git.GitException:无法克隆git@bitbucket.org:DAVID99WORLD / assessme.git
在hudson.plugins.git .GitAPI.clone(GitAPI.java:268)
在hudson.plugins.git.GitSCM $ 2.invoke(GitSCM.java:1122)$ b $在hudson.plugins.git.GitSCM $ 2.invoke b(GitSCM .java:1064)
at hudson.FilePath.act(F ilePath.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)
在hudson.model.AbstractBuild $ AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589)
在jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java :在hudson.model.Run.execute 88)
。在hudson.model.AbstractBuild $ AbstractBuildExecution.run(AbstractBuild.java:494)
(Run.java:1502)
。在哈德森。 maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)
在hudson.model.ResourceController.execute(ResourceController.java:88)
在hudson.model.Executor.run(Executor.java:236)
导致:hudson.plugins.git.GitException:命令git clone --progress -o origin git@bitbucket.org:DAVID99WORLD / assessme.git / var / lib / jenkins / jobs / Google adwords / workspace返回状态码128:
stdout:克隆到'/ var / lib / je nkins / jobs / Google adwords / workspace'...

stderr:主机密钥验证失败。
致命:远程终端意外挂起

有谁知道这个原因发生?根据我读过的文档〜/ .ssh是jenkins用户存在这个文件的正确目录。



编辑:我的jenkins用户没有known_hosts文件在〜/ .ssh文件中,但是我的根级别文件可以 - 应该吗?我可以用我的jenkins用户做一个克隆,并且没有提及jenkins用户的主机。

它可能与known_hosts文件无关。我想,你必须检查Jenkins是否能够读取你的公共SSH密钥。因此,您可能需要检查:/ etc / passwd中为Jenkins用户定义的home
$ b

  • home匹配〜/ .ssh

  • Jenkins用户可以访问他的主目录(至少在上面的所有dir上都是-x-x-x)
  • Jenkins用户可以访问id_rsa.pub文件
  • Jenkins实际上与Jenkins用户一起运行,而不是tomcat用户



另外,如果您删除当前的id_rsa.pub文件,会发生什么情况?它是否抱怨没有找到使用公钥?


I've got an ssh key in ~/.ssh/id_rsa.pub when I login as the jenkins user.

I've imported this into bitbucket correctly and it has accepted the key.

When I try to do a git clone (to the correct URL) I still get....

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

Does anyone know of a reason why this would occur? According to the documentation I've read ~/.ssh is the correct directory as the jenkins user for this file to exist.

EDIT : My jenkins user does not have a known_hosts file in ~/.ssh but my root level ones do - should it? I can do a clone with my jenkins user just fine and it doesn't mention the host at all as jenkins user.

解决方案

It is probably not related to the known_hosts file. I think, you have to check that Jenkins is able to read your public SSH key. Therefore, you might want to check that:

  • home defined for Jenkins user in /etc/passwd matches ~/.ssh
  • Jenkins user has access to his home directory (so at least --x--x--x on all dirs above)
  • Jenkins user has access to the id_rsa.pub file
  • Jenkins is actually running with Jenkins user and not e.g. tomcat user

Also, what happens if you remove your current id_rsa.pub file? Does it complain of not finding a public key to use?

这篇关于詹金斯发现无法找到ssh密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆