2012-08-23 164 views
2

當我以jenkins用戶身份登錄時,我在〜/ .ssh/id_rsa.pub中有一個ssh密鑰。Jenkins發現無法找到ssh密鑰

我已經正確導入到bitbucket中,它已經接受了密鑰。

當我嘗試做一個git克隆(正確的URL)我仍然得到....

Building in workspace /var/lib/jenkins/jobs/Google adwords/workspace 
Checkout:workspace//var/lib/jenkins/jobs/Google adwords/workspace - [email protected] 
Using strategy: Default 
Cloning the remote Git repository 
Cloning repository origin 
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:DAVID99WORLD/assessme.git 
hudson.plugins.git.GitException: Could not clone [email protected]: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 [email protected]: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用戶那樣提及主機。

+0

刪除我的答案,應該是一個評論。確保jenkins實際上以jenkins的形式運行。你在使用Winstone servlet還是其他的東西 - 比如Tomcat? –

+0

SO的焦點話題;屬於[sf]或[su] –

回答

2

它可能與known_hosts文件無關。我想,你必須檢查Jenkins是否能夠讀取你的公共SSH密鑰。因此,你可能要檢查的是:

  • 家在/ etc/passwd文件匹配詹金斯用戶定義的〜/ .ssh
  • 詹金斯用戶可以訪問到他的家目錄(這樣至少--x-- x - x上面的所有dirs)
  • Jenkins用戶可以訪問id_rsa.pub文件
  • Jenkins實際上正在運行Jenkins用戶而不是例如tomcat用戶

另外,如果您刪除當前的id_rsa.pub文件,會發生什麼情況?它是否抱怨沒有找到使用公鑰?

+0

你能編寫我們需要運行的macosx命令來執行此操作嗎?我有完全相同的問題。我真的瘋了它 http://stackoverflow.com/questions/13267964/configure-jenkins-to-connect-to-bitbucket – Claus

+0

@Claus這是很難做到這一點,因爲它很大程度上取決於服務器組態。 – Sebi