title: Capistrano: cap aborted! SSHKit::Runner::ExecuteError: Exception while executing on host
body: <p>I'm trying to deploy code with Capistrano 3 to Ubuntu server from GIT repository, but I'm getting this error.</p>
  
  <p>==========================================================================<br>
      Here is my Gemfile. </p>
  
  <pre><code>gem 'capistrano', '~&gt; 3.1.0'
  
  #//Use unicorn as the app server
  gem 'unicorn'
  
  #// Use Capistrano for deployment
  group :development do
  gem 'capistrano-rails'
  gem 'capistrano-bundler'
  gem 'capistrano-rbenv', "~&gt; 2.0"
  end
  
  source 'https://rubygems.org'
  </code></pre>
  
  <p>==========================================================================
      #deploy.rb</p>
  
  <pre><code>lock '3.1.0'
  
  #// Define the name of the application
  set :application, 'my_app'
  
  #// Define where can Capistrano access the source repository
  #// set :repo_url, 'https://github.com/[user name]/[application name].git'
  set :scm, :git
  set :repo_url, 'git@github.com:jaipratik/rw.git'
  
  set :use_sudo, true
  
  set :log_level, :debug
  
  #// Define where to put your application code
  set :deploy_to, "/var/www/my_app"
  
  set :pty, true
  
  set :format, :pretty
  </code></pre>
  
  <p>==========================================================================
      #// production.rb</p>
  
  <pre><code>role :app, %w{ubuntu@{IP/Host}}
  
  server '{IP/Host}', user: 'ubuntu', roles: %w{web app}
  
  set :ssh_options, {
  keys: %w(/Users/jay/.ssh/id_rsa),
  forward_agent: false,
  user: 'user'
  # auth_methods: %w(password)
  }
  </code></pre>
  
  <p>==========================================================================
  result for     $ bundle exec cap production deploy --trace</p>
  
  <pre><code>** Invoke production (first_time)
  ** Execute production
  ** Invoke load:defaults (first_time)
  ** Execute load:defaults
  ** Invoke deploy (first_time)
  ** Execute deploy
  ** Invoke deploy:starting (first_time)
  ** Execute deploy:starting
  ** Invoke deploy:check (first_time)
  ** Execute deploy:check
  ** Invoke git:check (first_time)
  ** Invoke git:wrapper (first_time)
  ** Execute git:wrapper
  INFO[f8299d4f] Running /usr/bin/env mkdir -p /tmp/my_app/ on {IP/Host}
  DEBUG[f8299d4f] Command: /usr/bin/env mkdir -p /tmp/my_app/
  INFO[f8299d4f] Finished in 0.723 seconds with exit status 0 (successful).
  DEBUGUploading /tmp/my_app/git-ssh.sh 0.0%
  INFOUploading /tmp/my_app/git-ssh.sh 100.0%
  INFO[b509dfb7] Running /usr/bin/env chmod +x /tmp/my_app/git-ssh.sh on {IP/Host}
  DEBUG[b509dfb7] Command: /usr/bin/env chmod +x /tmp/my_app/git-ssh.sh
  INFO[b509dfb7] Finished in 0.084 seconds with exit status 0 (successful).
  ** Execute git:check
  DEBUG[9646aea0] Running /usr/bin/env git ls-remote git@github.com:jaipratik/rw.git on {IP/Host}
  DEBUG[9646aea0] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/my_app/git-ssh.sh /usr/bin/env git ls-remote git@github.com:jaipratik/rw.git )
  DEBUG[9646aea0] c452c845bb80f72d3023557d2ea8f776950c659f
  DEBUG[9646aea0]
  DEBUG[9646aea0] HEAD
  DEBUG[9646aea0]
  DEBUG[9646aea0] c452c845bb80f72d3023557d2ea8f776950c659f
  DEBUG[9646aea0]
  DEBUG[9646aea0] refs/heads/master
  DEBUG[9646aea0]
  DEBUG[9646aea0] Finished in 0.940 seconds with exit status 0 (successful).
  ** Invoke deploy:check:directories (first_time)
  ** Execute deploy:check:directories
  INFO[fa4b1f56] Running /usr/bin/env mkdir -pv /var/www/my_app/shared /var/www/my_app/releases on {IP/Host}
  DEBUG[fa4b1f56] Command: /usr/bin/env mkdir -pv /var/www/my_app/shared /var/www/my_app/releases
  INFO[fa4b1f56] Finished in 0.086 seconds with exit status 0 (successful).
  ** Invoke deploy:check:linked_dirs (first_time)
  ** Execute deploy:check:linked_dirs
  ** Invoke deploy:check:make_linked_dirs (first_time)
  ** Execute deploy:check:make_linked_dirs
  ** Invoke deploy:check:linked_files (first_time)
  ** Execute deploy:check:linked_files
  ** Invoke deploy:started (first_time)
  ** Execute deploy:started
  ** Invoke deploy:updating (first_time)
  ** Invoke deploy:new_release_path (first_time)
  ** Execute deploy:new_release_path
  ** Execute deploy:updating
  ** Invoke git:create_release (first_time)
  ** Invoke git:update (first_time)
  ** Invoke git:clone (first_time)
  ** Invoke git:wrapper
  ** Execute git:clone
  DEBUG[fa77f295] Running /usr/bin/env [ -f /var/www/my_app/repo/HEAD ] on {IP/Host}
  DEBUG[fa77f295] Command: [ -f /var/www/my_app/repo/HEAD ]
  DEBUG[fa77f295] Finished in 0.081 seconds with exit status 1 (failed).
  DEBUG[0cc407cc] Running /usr/bin/env if test ! -d /var/www/my_app; then echo "Directory does not exist '/var/www/my_app'" 1&gt;&amp;2; false; fi on {IP/Host}
  DEBUG[0cc407cc] Command: if test ! -d /var/www/my_app; then echo "Directory does not exist '/var/www/my_app'" 1&gt;&amp;2; false; fi
  DEBUG[0cc407cc] Finished in 0.075 seconds with exit status 0 (successful).
  INFO[de52ca0e] Running /usr/bin/env git clone --mirror git@github.com:jaipratik/rw.git /var/www/my_app/repo on {IP/Host}`enter code here`
  DEBUG[de52ca0e] Command: cd /var/www/my_app &amp;&amp; ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/my_app/git-ssh.sh /usr/bin/env git clone --mirror git@github.com:jaipratik/rw.git /var/www/my_app/repo )
  cap aborted!
  SSHKit::Runner::ExecuteError: Exception while executing on host {IP/Host}: git exit status: 1
  git stdout: Nothing written
  git stderr: Nothing written
  /Users/jay/.rvm/gems/ruby-2.1.0/gems/sshkit-1.5.1/
  </code></pre>