title: How to link Jenkins to private Github repository?
body: <p>My goal is to pull a Private Github Repository to Jenkins.</p>
  
  <p>Here are some backgrounds:</p>
  
  <ol>
  <li>MacOS </li>
  <li>Jenkins hosted locally, <code>localhost:8080</code> </li>
  <li>Installed Git plugin and Github plugin in Jenkins. </li>
  <li>If I turn the repository to Public, everything is good in Jenkins. </li>
  <li>From commandline, I can do "git clone" that private repo with the same credentials I used in Jenkins.</li>
  </ol>
  
  <p>But when I turn it to Private and use it as the Source for Jenkins, it's broken.</p>
  
  <p>The errors are:</p>
  
  <pre><code>Building in workspace /Users/Shared/Jenkins/Home/jobs/TestFramework/workspace
       &gt; /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       &gt; /usr/bin/git config remote.origin.url https://github.com/XXXXXXX/testframework.git # timeout=10
      Fetching upstream changes from https://github.com/XXXXXXX/testframework.git
       &gt; /usr/bin/git --version # timeout=10
      using GIT_ASKPASS to set credentials 
       &gt; /usr/bin/git fetch --tags --progress https://github.com/XXXXXXX/testframework.git +refs/heads/*:refs/remotes/origin/* # timeout=5
      ERROR: Timeout after 5 minutes
      ERROR: Error fetching remote repo 'origin'
      hudson.plugins.git.GitException: Failed to fetch from https://github.com/XXXXXXX/testframework.git
          at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:806)
          at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1070)
          at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
          at hudson.scm.SCM.checkout(SCM.java:496)
          at hudson.model.AbstractProject.checkout(AbstractProject.java:1278)
          at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
          at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
          at hudson.model.Run.execute(Run.java:1728)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:405)
      Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress https://github.com/XXXXXXX/testframework.git +refs/heads/*:refs/remotes/origin/*" returned status code 143:
  </code></pre>
  
  <p><strong>I tried a few suggestions online:</strong></p>
  
  <ol>
  <li>ssh-keygen to /Users/shared/jenkins/.ssh/id_rsa</li>
  <li>ssh-keygen to /Users/jason/.ssh/id_rsa</li>
  <li>Add both corresponding "id_rsa.pub" to private repository "Settings" => "Deploy keys".</li>
  </ol>
  
  <p>But still not working.</p>