Capifony forward_agent not working. Asks for GitHub password and fails

283 views Asked by At

I am using capifony to deploy a symfony2 web app onto Ubuntu. I have the following in my deploy.rb:

set :repository, "[email protected]:Username/Repo.git"
set :branch,      "develop"
set :scm_verbose, true
set :deploy_via,  :remote_cache

default_run_options[:pty] = true
set :ssh_options, {:forward_agent => true}
ssh_options[:keys] = ["/Users/myuser/Sites/file.pem"]
ssh_options[:auth_methods] = ["publickey"]

Capifony is able to ssh in but then asks for a GitHub password during the deploy. I enter the password correctly but it then give me the following authentication fail error:

remote: Invalid username or password
fatal: Authentication failed for 'https://[email protected]/UserName/Repo.git/'

I don't know why it is asking for my Github password, and why it doesn't use agent forwarding to ssh to github?

I have added my public key from the server to GitHub but I am a bit confused about these keys, and my local keys? does it forward my local key or does it use the server one? What permissions do I need to set etc?

I am using capifony v2.8.6 I recently had to reinstall ruby and capifony die to upgrading to El Capitan which stopped capifony from working altogether. This is when my problems started. I am deploying to Ubuntu 14.04

I have tried editing /etc/ssh/ssh_config on the server and adding

ForwardAgent yes

Then restarting ssh, but this has no effect.

Thanks

1

There are 1 answers

3
Soifou On

I do not use Capifony anymore and cannot comment yet so I try to answer :)

First, if you deploy from your local machine (your Mac), check :

  • your ssh-agent is started,
  • you can git clone one of your github repo
  • you can ssh to your Ubuntu server

Then you could just set this two line below.

default_run_options[:pty] = true ssh_options[:forward_agent] = true

No need to set other ssh_options nor to tweak you ssh server config , it might be very confusing.

Second, you can test if ssh forwarding is working for the selected environment by creating a simple rake tasks inside your project :

namespace :ssh do desc "Check if agent forwarding is working" task :forwarding do on roles(:all) do |h| if test("env | grep SSH_AUTH_SOCK") info "Agent forwarding is up to #{h}" else error "Agent forwarding is NOT up to #{h}" end end end end

And test with a cap [env] ssh:forwarding

Finally, if you reinstalled ruby/capifony recently, try to make the switch to Capistrano v3 and its Symfony gem instead, it really worth a try.