1

I installed Jenkins as daemon (on mac os x 10.7) and I am using 'real-os-user' as JENKINS USER.

I am trying to configure a job with git project (helloworld) but I get the following error:

    Failed to connect to repository : Command "git ls-remote -h git-server-name:helloworld HEAD" returned status code 128:
    stdout: 
    stderr: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,keyboard-interactive). 
    fatal: The remote end hung up unexpectedly

If I run the 'git ls-remote -h git-server-name:helloworld HEAD' in terminal window, it works fine.

I printed 'env' variables, and I see Jenkins is using 'real-os-user'..

Any ideas are appreciated. Thanks

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Madhu
  • 63
  • 6
  • See if this solve your problem http://stackoverflow.com/questions/14064502/git-push-gives-permission-denied-publickey-fatal-the-remote-end-hung-up-unex – Siddharth Dec 28 '12 at 06:37

1 Answers1

0

git-server-name:helloworld is an ssh address, so you need to make sure that:

  • Jenkins does has defined (when executing the job) the same HOME than your shell session
  • $HOME/.ssh exists and contain the config file, id_rsa and id_rsa.pub (private and public key): test for the existence of those file in your helloworld Jenkins jobs for testing purpose.
  • Siddharth references in the comments the fact that your private key might have a passphrase that you need to add to an ssh-agent.
    Try first with a passphrase-less key that you would register to gitolite.

Note that if you did rename your public and private key after the user's name (as gitolite expects its public key to be named after the user id), your config file needs to reference that new name:

 .ssh
    real-os-user
    real-os-user.pub
    config

With config file:

Host git-server-name
    HostName git-server-name
    IdentityFile ~/.ssh/real-os-user
    User git # or whatever account is managing gitolite on the server side

Considering that your git ls-remote, this shouldn't be an issue.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you VonC for your feedback. 1) I printed 'env' variables. I see JENKINS_HOME and HOME variables. HOME is pointing to the real-user-home directory and it has .ssh folder and also I copied .ssh folder to JENKINS_HOME and tried but no luck. .ssh folder has config folder, .pub and private keys and known_hosts file. 2) Let me try with passphrase-less key. I forgot completely about it. 3) I didn't rename the real-os-user that authenticates with git server, so that is not an issue as you said. – Madhu Dec 28 '12 at 17:30
  • @Madhu Excellent. Any issue with a passphrase-protected key is likely to be related with a missing `ssh-add` command (as in http://stackoverflow.com/a/13443777/6309) – VonC Dec 30 '12 at 20:24
  • Thanks for the link VonC. I will give it a try. – Madhu Dec 31 '12 at 22:10