title: Jenkins hangs on Mac slave when cloning from Gitlab instance
body: <p>We are trying to build an iOS app through a Jenkins job, but we are unable to clone the repository from our Gitlab instance. As of now, Jenkins hangs (until the 10 minute timeout) when git fetches the references.</p>
  
  <p>Below is the Jenkins output: </p>
  
  <pre><code>Started by user &lt;USER&gt;
  [EnvInject] - Loading node environment variables.
  Building remotely on Mac_Slave in workspace /Users/&lt;MAC USER&gt;/Documents/Jenkins/workspace/&lt;REPO&gt;
   &gt; git rev-parse --is-inside-work-tree
  Fetching changes from the remote Git repository
   &gt; git config remote.origin.url git@&lt;GITLAB&gt;:&lt;USERNAME&gt;/&lt;REPO&gt;.git
  Fetching upstream changes from git@&lt;GITLAB&gt;:&lt;USERNAME&gt;/&lt;REPO&gt;.git
   &gt; git --version
  using GIT_SSH to set credentials &lt;MAC SLAVE&gt;
   &gt; git fetch --tags --progress git@&lt;GITLAB&gt;:&lt;USERNAME&gt;/&lt;REPO&gt;.git +refs/heads/*:refs/remotes/origin/*
  ERROR: Timeout after 10 minutes
  FATAL: Failed to fetch from git@&lt;GITLAB&gt;:&lt;USERNAME&gt;/&lt;REPO&gt;.git
  hudson.plugins.git.GitException: Failed to fetch from git@&lt;GITLAB&gt;:&lt;USERNAME&gt;/&lt;REPO&gt;.git
      at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:623)
      at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:855)
      at hudson.plugins.git.GitSCM.checkout(GitSCM.java:880)
      at hudson.model.AbstractProject.checkout(AbstractProject.java:1251)
      at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:605)
      at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514)
      at hudson.model.Run.execute(Run.java:1703)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:231)
  Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@&lt;GITLAB&gt;:&lt;USERNAME&gt;/&lt;REPO&gt;.git +refs/heads/*:refs/remotes/origin/*" returned status code 143:
  stdout: 
  stderr: 
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1307)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1169)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:257)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
      at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      at hudson.remoting.Request$2.run(Request.java:328)
      at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at hudson.remoting.Engine$1$1.run(Engine.java:63)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>We have added the Mac's SSH public key as the deploy key for the repository and we used the Mac's SSH private key as the credentials, but for some reason, it won't work. Any thoughts?</p>
  
  <p>EDIT: Looking at the logs on the Mac slave, I noticed that it prompts the user to "Enter passphrase for key <code>'/var/folders/92/&lt;RANDOM STRING OF CHARACTERS&gt;/T/ssh&lt;RANDOM STRING OF NUMBERS&gt;key':"</code> and if I manually enter the passphrase for the SSH key, it works. However this solution isn't ideal for an automated build system.</p>
  
  <p>Digging further, if I actually go to the <code>'/var/folders/92/&lt;RANDOM STRING&gt;/T/'</code> folder, I see a few files. When the Mac slave is prompted for the passphrase, a <code>ssh&lt;RANDOM NUMBERS&gt;key</code> file, a <code>ssh&lt;DIFF RANDOM NUMBERS&gt;.sh</code> file, and a <code>pass&lt;OTHER DIFF RANDOM NUMBERS&gt;.sh</code> file appear. The <code>ssh&lt;...&gt;key</code> file contains the SSH private key, the <code>ssh&lt;...&gt;.sh</code> file contains an ssh command using that private key, and the <code>pass&lt;...&gt;.sh</code> file contains a command to echo the SSH passphrase.</p>