2012-10-30 304 views
2

我正在通过在/ etc/sysconfig/hudson中将配置更改为“HUDSON_USER = myuser”作为自定义用户运行Hudson服务(守护进程)。我已经确认SSH服务器已添加RSA密钥,该密钥存在于/home/myuser/.ssh中。Hudson SSH密钥权限被拒绝

当我通过以“myuser”身份登录系统运行Hudson时,它可以工作并可以从git存储库中获取代码。

nohup java -jar hudson.war --httpPort=8081 > /home/myuser/hudson.out 2>&1 & 

当我运行哈德森守护进程,然后在运行建立我无法提取从git仓库,并显示以下日志与权限被拒绝的错误来源。

Started by user anonymous 
Checkout:workspace//home/myuser/.hudson/jobs/test/workspace - [email protected] 
Using strategy: Default 
Last Built Revision: Revision a0d97d4d7bf5ee08124f76e5eb98bab354754cad (origin/master) 
Checkout:workspace//home/myuser/.hudson/jobs/test/workspace - [email protected] 
Fetching changes from the remote Git repository 
Fetching upstream changes from ssh://[email protected]:20/home/git-repos/test-proj.git 
ERROR: Problem fetching from origin/origin - could be unavailable. Continuing anyway 
ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=ERROR: (Underlying report) : Error performing command: /usr/bin/git fetch -t ssh://[email protected]:20/home/git-repos/test-proj.git +refs/heads/*:refs/remotes/origin/* 
Command "/usr/bin/git fetch -t ssh://[email protected]:20/home/git-repos/test-proj.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 
fatal: The remote end hung up unexpectedly 

ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=ERROR: Could not fetch from any repository 
ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=FATAL: Could not fetch from any repository 
ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=hudson.plugins.git.GitException: Could not fetch from any repository 
     at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:887) 
     at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:845) 
     at hudson.FilePath.act(FilePath.java:758) 
     at hudson.FilePath.act(FilePath.java:740) 
     at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:845) 
     at hudson.plugins.git.GitSCM.checkout(GitSCM.java:622) 
     at hudson.model.AbstractProject.checkout(AbstractProject.java:1483) 
     at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:507) 
     at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:424) 
     at hudson.model.Run.run(Run.java:1366) 
     at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) 
     at hudson.model.ResourceController.execute(ResourceController.java:88) 
     at hudson.model.Executor.run(Executor.java:145) 
+0

忘了提多说一点,运行哈德森,因为它的工作原理java命令的时候,问我密码的RSA密钥。在使用Hudson作为服务时,我如何传递类似的密码。 –

+0

我已经尝试过下面的建议,但没有帮助http://stackoverflow.com/questions/2447878/how-to-configure-hudson-and-git-plugin-with-an-ssh-key http://stackoverflow.com/questions/6515039/jenkins-git-permission-denied-publickey http://stackoverflow.com/questions/10224574/jenkins-hudson-cant-connect-to-github-repo –

+1

这是一些Linux发行版Hudson包吗?这将告诉我们你在'/ etc/sysconfig/hudson'中设置什么以及它是如何作为守护进程运行的。 – rakslice

回答

2

我已将RSA密钥更改为密码更少并添加到Github服务器。它解决了在运行hudson作为init.d服务时从Git获取源代码的问题。

此外,我这是怎么添加关键Github上,任何人谁正在寻找如何https://help.github.com/articles/generating-ssh-keys