How to configure Hudson and git plugin with an SSH key How to configure Hudson and git plugin with an SSH key git git

How to configure Hudson and git plugin with an SSH key


Another important note for windows (which I want to attach to this answer because I found this question very quickly, but found this additional detail I needed only after hours of searching):

Git wants the %HOME% environment variable set to your user's directory (I.E. C:\Documents and Settings\hudsonuser)... that's how it knows to look in there for the .ssh dir with the key files!

I found this out here on server fault (but don't have enough reputation there to upvote it).


We use Hudson, checking out the source code from git with an ssh key. We actually have Hudson on an ubuntu server, however. Hudson's ssh key pair lives in ~hudson/id_rsa and ~hudson/id_rsa.pub

So, adapting our advice for a Windows set-up:

The Windows-based developers on our team use MSysGit and regularly check out code via git over ssh -- but not using Putty/Pageant. We found Pageant to be painful due to some protocol errors with the login. Instead, they configured git to use openSSH (it's one of the options during the install). Their public/private key pair then lives in ~username/id_rsa and ~username/id_rsa.pub and it all works.

So, I'd recommend changing your git config to use OpenSSH rather than pageant. If nothing else, you won't need to worry about starting pageant.

You can use PuttyGen to generate the key. However, if you are using OpenSSH rather than pageant, you will need to export a suitable private key (from one of the menus at the top of PuttyGen) and save it as id_rsa, and copy-and-paste the public key from PuttyGen's GUI (it shows but won't save a suitable version for OpenSSH) and save that as id_rsa.pub. This is because Putty uses a slightly different format for the key than OpenSSH does.

Alternatively, of course, you can always host your hudson server on a ubuntu server (either a real one or through VirtualBox)


I found I had to use a different tack to get this working on Ubuntu (with Jenkins, not Hudson, though otherwise it looks like basically the same problem. I checked the %HOME% environment variable through the Jenkins GUI and that looked right.

The key I wanted to use to identify Jenkins to the Github private repository already existed. I copied those to /var/lib/jenkins/.ssh -- both the id_rsa and the id_rsa.pub file for that key and account.

Initially I copied these as "root" and they were inaccessible to Jenkins so I was still getting errors (confusingly, the errors asked me to enter a passphrase when there wasn't any). So I did chown, chmod and chgrp to set these to be available to Jenkins.

I tested this by doing a git clone while logged in as the Jenkins user.

I know this path is specific to Ubuntu, but a similar setup making sure the key files are available, in the right place, and testing on the command line just doing git clone git:myrepo, might at least identify where Windows is different.