title: Capistrano deployment from Windows using forward_agent option: "Error reading response length from authentication socket."
body: <p>I'm trying to deploy a project using Capistrano.  My development machine is running Windows 7; the server I'm deploying onto is Linux.</p>
  
  <p>In the deploy.rb script, the following is set:</p>
  
  <pre><code>ssh_options[:forward_agent] = true
  </code></pre>
  
  <p>The Capistrano script starts off by running a git command locally, at which point I'm prompted for the passphrase for my SSH key:</p>
  
  <pre><code>* executing `deploy:update_code'
  executing locally: "git ls-remote git@github.com:pathto/gitproject.git develop"
  Enter passphrase for key '/c/Users/Sam/.ssh/id_rsa':
  command finished in 6999ms
  </code></pre>
  
  <p>(I've removed the real git path from the above as you can probably see.)</p>
  
  <p>I enter my passphrase and this works fine.  However, Capistrano then tries to do something similar on the remote machine (renamed to staging-server.com in the below) and I get an error -- see the final line of this extract:</p>
  
  <pre><code>[staging-server.com] executing command
  [staging-server.com] sh -c 'git clone git@github.com:pathto/gitproject.git /home/perstest/releases/20120412074500 &amp;&amp; cd
  /home/perstest/releases/20120412074500 &amp;&amp; git checkout -b deploy 50eaf06d06d66fd20c3e55038276f420d8c308a8 &amp;&amp; (echo 50eaf06d06d66fd20c3e55038
  276f420d8c308a8 &gt; /home/perstest/releases/20120412074500/REVISION)'
   ** [staging-server.com :: out] Initialized empty Git repository in /home/perstest/releases/20120412074500/.git/
   ** [staging-server.com :: err] Error reading response length from authentication socket.
  </code></pre>
  
  <p>If I comment out the forward_agent line in deploy.rb, this install succeeds, presumably using the key from the deployment server itself.</p>
  
  <p>My SSH key seems to be working - after all, the initial git command works, I can use it in git push/pull and ssh -T git@github.com reports what it should (as recommended on <a href="http://help.github.com/win-set-up-git/">github:help</a>).</p>
  
  <p>I assumed that my machine was not serving keys when asked for them by the remote server.  After an awful lot of Googling, I found the recommendations at <a href="http://hustoknow.blogspot.co.uk/2011/06/ssh-agent-and-agent-forwarding-on.html">http://hustoknow.blogspot.co.uk/2011/06/ssh-agent-and-agent-forwarding-on.html</a>, which explain how to get ssh-agent running on startup.  I was doing all this from the command-prompt, so I then switched to git-bash and set up my .bash_profile for that to include the script I've linked to.</p>
  
  <p>After adding this, I was prompted for my passphrase when first launching git bash and I could then connect to github using the SSH key (without having to re-enter passphrase).  Furthermore, ssh-add -L reported that there was indeed a key available.  So everything seems to be set up correctly!</p>
  
  <p>However, I still get the "Error reading response length from authentication socket." error.</p>
  
  <p>Any ideas?  This works for my colleague (same deploy.rb file) whose development machine is Linux.</p>