2

I am running Hudson service (daemon) as custom user by making configuration changes in /etc/sysconfig/hudson as "HUDSON_USER=myuser". I have confirmed that SSH server has RSA key added that is present in /home/myuser/.ssh.

When I run Hudson as below by logging into system as "myuser" it works and could fetch code from git repository.

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

When I run Hudson daemon then while running build I couldn't fetch source from git repository and shows following log with Permission denied error.

Started by user anonymous
Checkout:workspace / /home/myuser/.hudson/jobs/test/workspace - hudson.remoting.LocalChannel@6083969e
Using strategy: Default
Last Built Revision: Revision a0d97d4d7bf5ee08124f76e5eb98bab354754cad (origin/master)
Checkout:workspace / /home/myuser/.hudson/jobs/test/workspace - hudson.remoting.LocalChannel@6083969e
Fetching changes from the remote Git repository
Fetching upstream changes from ssh://myuser@10.10.10.10: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://myuser@10.10.10.10:20/home/git-repos/test-proj.git +refs/heads/*:refs/remotes/origin/*
Command "/usr/bin/git fetch -t ssh://myuser@10.10.10.10: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)
rakslice
  • 8,742
  • 4
  • 53
  • 57
Manish Devraj
  • 701
  • 3
  • 11
  • 27
  • Forgot to mention one more point, when running Hudson as java command it works and ask me password for RSA key. How can I pass similar password when using Hudson as service. – Manish Devraj Oct 30 '12 at 11:39
  • I have already tried following suggestions but no help 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 – Manish Devraj Oct 30 '12 at 14:37
  • 1
    Is this with some linux distro Hudson package? That would tell us what you mean by setting things in `/etc/sysconfig/hudson` and how it's running as a daemon. – rakslice Nov 01 '12 at 01:06
  • Also, if you set the private key to have an empty password, ssh won't stop to prompt for one. – rakslice Nov 01 '12 at 01:14
  • Yes it is running as hudson service. Details of packaged for Centos is provided at http://wiki.hudson-ci.org/display/HUDSON/Installing+Hudson+using+RPM+repository – Manish Devraj Nov 01 '12 at 10:10
  • Thank you **rakslice**, your suggestion helped me. – Manish Devraj Nov 01 '12 at 10:13

1 Answers1

2

I have changed RSA key to be password less and added to Github server. It solved the problem of fetching source from Git when running hudson as init.d service.

Additionally, this is how I added key to Github, for anyone who is searching HOW TO https://help.github.com/articles/generating-ssh-keys

Manish Devraj
  • 701
  • 3
  • 11
  • 27