Search code examples
ruby-on-railssshgithubcapistranodreamhost

Why did I have to upload my private key to my server to get Capistrano to work with GitHub?


From what I've read, including this article on GitHub itself, by using ssh agent forwarding, I should not have needed to upload my private id_rsa key to my server in order for Capistrano to connect to GitHub. Yet, until I uploaded it, cap deploy would fail trying to pull from GitHub saying "Permission denied (publickey)".

A little about my setup: My server is a shared Dreamhost server. I'm on Windows using the mysysgit Git Bash as my CLI. I previously set up passwordless ssh login to the Dreamhost server by copying my public key to authorized_keys. I can push to GitHub from my dev. Another symptom was that I could ssh into GitHub from my box, but from the server it gave the same error as above. That tipped me off about uploading my private key to resolve the issue. But it shouldn't have been necessary as I understand it.

Here's my deploy.rb:

default_run_options[:pty] = true
set :domain, "myactualdomain"
set :user, "myusernameeverywhere"

# source
set :scm, :git
set :repository,  "[email protected]:#{user}/#{myreponame}.git"
set :branch, "master"
ssh_options[:forward_agent] = true
set :deploy_via, :remote_cache
set :scm_verbose, true

# deployment
set :use_sudo, false
set :deploy_to, "/home/#{user}/#{domain}"
role :web, "#{domain}"
role :app, "#{domain}"
role :db,  "#{domain}", :primary => true

Why did I have to upload my private key? Is there a way to handle this where that isn't necessary?


Solution

  • Agent forwarding is handled by the net-ssh gem. Did you try to update it to >=1.1.0 ?