1

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

set :repository, "git@github.com: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://UserName@github.com/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

Patrick
  • 358
  • 6
  • 20

1 Answers1

0

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.

Soifou
  • 76
  • 3
  • Hi, thanks for the advice. I have upgraded to capistrano v3 and symfony gem. I am looking at authentication docs here - http://capistranorb.com/documentation/getting-started/authentication-and-authorisation/ I am a bit confused about the difference between my EC2 .pem file and the id_rsa ssh key. Do I need/can I use both? – Patrick Oct 13 '15 at 07:59
  • I have started a new question based on my capistrano 3 script - http://stackoverflow.com/questions/33105995/capistrano-3-deploy-fails-connecting-to-github-permission-denied-publickey – Patrick Oct 13 '15 at 14:58
  • I think you have to convert your Amazon pem file into regular ssk key and add it to your github account, see here for more details http://stackoverflow.com/questions/24421096/deploying-to-ec2-instance-failing-when-access-github-private-repo – Soifou Oct 14 '15 at 09:16