title: ssh problems during deploy with capistrano
body: <p>I'm getting permissions errors while trying to deploy my rails app to a friend's server. I'm running rails 3.1.3, ruby-1.9.2-p290, capistrano 2.11.2, Mac OS 10.6.8, and we have ssh keys set up. However, we can't figure out where the permission issues are coming from. We think it might be that capistrano is trying to push the code from the git repo AS THE GIT USER to the deploy directory, or something like that. But this is our first deploy attempt, so we're not sure. Any help would be hugely appreciated!</p>
  
  <p>Oh, and here's some more details that my friend told me to specify:
  appsrv-04.example.ca is the canonical FQDN of the host, and project.example.ca is a CNAME pointing to the A record of appsrv-04.example.ca. The known_hosts file for the git and deploy users contains all of appsrv-04, appsrv-04.example.ca,  project, and project.example.ca.</p>
  
  <p>Below is the output from running cap deploy:update.</p>
  
  <pre><code>[user@workstation]~/Code/projectapi $ cap deploy:update
   * executing `deploy:update'
    ** transaction: start
    * executing `deploy:update_code'
  updating the cached checkout on all servers
  executing locally: "git ls-remote ssh://git@appsrv-04.example.ca/usr/local/git_root/projectapi.git master"
  Enter passphrase for key '/Users/user/.ssh/id_rsa': 
   command finished in 4478ms
  * executing "if [ -d /usr/local/www/sites/project.example.ca/public/shared/cached-copy ]; then cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy &amp;&amp; git fetch -q origin &amp;&amp; git fetch --tags -q origin &amp;&amp; git reset -q --hard e71d220f299271522517f7b4f028a9275d53326a &amp;&amp; git clean -q -d -x -f; else git clone -q ssh://git@appsrv-04.example.ca/usr/local/git_root/projectapi.git /usr/local/www/sites/project.example.ca/public/shared/cached-copy &amp;&amp; cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy &amp;&amp; git checkout -q -b deploy e71d220f299271522517f7b4f028a9275d53326a; fi"
  servers: ["project.example.ca"]
  Enter passphrase for /Users/user/.ssh/id_dsa: 
  [project.example.ca] executing command
   ** [project.example.ca :: err] Permission denied, please try again.
   ** [project.example.ca :: err] Permission denied, please try again.
   ** [project.example.ca :: err] Permission denied (publickey,password).
   ** [project.example.ca :: err] fatal: The remote end hung up unexpectedly
    command finished in 650ms
  *** [deploy:update_code] rolling back
   * executing "rm -rf /usr/local/www/sites/project.example.ca/public/releases/20120222225453; true"
  servers: ["project.example.ca"]
  [project.example.ca] executing command
  command finished in 465ms
  failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '1.9.2-p290@project' -c 'if [ -d /usr/local/www/sites/project.example.ca/public/shared/cached-copy ]; then cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy &amp;&amp; git fetch -q origin &amp;&amp; git fetch --tags -q origin &amp;&amp; git reset -q --hard e71d220f299271522517f7b4f028a9275d53326a &amp;&amp; git clean -q -d -x -f; else git clone -q ssh://git@appsrv-04.example.ca/usr/local/git_root/projectapi.git /usr/local/www/sites/project.example.ca/public/shared/cached-copy &amp;&amp; cd /usr/local/www/sites/project.example.ca/public/shared/cached-copy &amp;&amp; git checkout -q -b deploy e71d220f299271522517f7b4f028a9275d53326a; fi'" on project.example.ca
  </code></pre>
  
  <p>And here's my deploy file:</p>
  
  <pre><code>$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) 
  require "rvm/capistrano"          
  
  set :application, "Project"
  
  set :scm, "git"
  set :repository,  "ssh://git@appsrv-04.example.ca/usr/local/git_root/project.git"
  set :user, "deploy"
  
  #set :rvm_bin_path, "/usr/local/rvm/bin"
  set :rvm_ruby_string, "1.9.2-p290@project"
  
  ssh_options[:forward_agent] = true
  
  set :branch, "master"
  
  set :deploy_via, :remote_cache
  
  set :deploy_to, "/usr/local/www/sites/project.example.ca/public/"
  
  set :use_sudo, false
  
  set :domain, 'project.example.ca'
  
  role :app, domain
  role :web, domain
  role :db,  domain, :primary =&gt; true
  </code></pre>