title: Capistrano local git repository cloning to remote asks for password despite SSH keys
body: <p>Totally new to Capistrano. </p>
  
  <p>I have a local git repository that I want to publish to my remote server. I've followed other answers here and came up with this configuration:</p>
  
  <pre><code>require 'bundler/capistrano'
  
  set :application, "app_name"
  set :repository, '~/Dropbox/app/.git'
  set :user, 'user_name'
  set :deploy_to, 'ssh://remote_host/~/railsApps/app_name'
  set :scm_verbose, true
  set :deploy_via, :copy
  
  default_run_options[:pty] = true
  
  server "remote_server", :web, :app, :db, :primary =&gt; true
  
  set :scm, :git
  set :branch, "master"
  
  ssh_options[:keys] = %w(~/.ssh/id_rsa)
  
  after "deploy:restart", "deploy:cleanup"
  </code></pre>
  
  <p>This no longer asks for a password for the remote server, but fails always with the following error:</p>
  
  <pre><code>The --deployment flag requires a Gemfile.lock. Please make sure you have checked your Gemfile.lock into version control before deploying.
  </code></pre>
  
  <p>I am definitely including the Gemfile.lock file in my git repo. </p>
  
  <p>If I change the Capistrano configuration to clone from the remote git folder to which I push (which is in that same server) then I don't get an error but it asks for my password every time I try to connect. </p>
  
  <p>Help please. </p>
  
  <p><strong>Note</strong> that SSH key pairing works fine when used from the CLI for regular SSH connection.</p>
  
  <p><strong>Solution</strong></p>
  
  <p>Thanks to Tigraine I was able to solve it. In the hopes that this helps someone else, here is what finally did the trick:</p>
  
  <p>Tigraine is correct in that the paths are local to the remote server, but I was getting an error when trying to use local paths, Capistrano kept searching on my local machine and throwing errors when it couldn't find those paths. </p>
  
  <p>What I had to do was add the <code>local_repository</code> to the config and then everything worked. So the bits I changed are these:</p>
  
  <pre><code>set :local_repository, '~/Dropbox/app_name/.git'
  set :repository, '~/railsApps/app_name.git'
  set :deploy_to, '~/railsApps/app_name'
  </code></pre>
  
  <p>The <code>local_repository</code> path is local to my machine and the <code>repository</code> and <code>deploy_to</code> paths are local to the remote server.</p>