Install Jenkins on Windows with SSH support for private GitHub repositories
GitHub pull requests fail
Out of the box installations of Jenkins with the Git and SSH plugins will not work when attempting to pull a private repository from GitHub.
PSExec.exe PS Tool by Microsoft
The first step to fix this issue I found was to download PSTools and extract the tools to a convenient location on the build server (e.g. c:\Programs\PSTools is there I extracted mine).
Generate a new SSH key just for Jenkins using PSExec or PSExec64
-
First open the Command prompt and “Run as Administrator”.
-
Once the command prompt is open navigate to the PSTools directory.
-
From the command prompt we need to run git-bash using PSExec or PSExec64 as the Local Service, which Jenkins is running on the build server as by default.
-
We will use the -i switch to run PSExec as interactive and the -s switch to run git-bash as the local service
-
Follow the instructions for creating a ssh key on GitHub - Generating a new SSH key and adding it to the ssh-agent
-
If you are on a 64bit Windows system, then copy the .ssh folder to C:\Windows\SysWOW64\config\systemprofile.ssh (this was not needed on my 64bit Windows system, but there where some instructions that indicated the .ssh files should be stored there, something to keep in mind if you are having problems still).
-
Add the public SSH key to your github keys.
Your Commandline should look similar to this:
C:\Programs\PSTools> PSExec.exe -i -s C:\Programs\Git\git-bash
Create the Jenkins Credentials
The hard part is over! Now just create the credentials to be used in Jenkins. Use your own Username and the passphrase used to create the SSH Key.
This is what it should look like now (with your own private github repo and user name:
Run a test pull request to verify, and your done.
Save and run a test pull request and your should no longer have any further problems with having Jenkins use SSH on your Windows build machine.