Search code examples
amazon-ec2capistrano

Capistrano deploy - Permission denied


I'm trying to deploy my application with capistrano but I'm having some problems. My machine is a ec2 amazon and I have the .pem locally. I can do ssh and run commands with no problem, but for cap production deploy I get the following error:

     DEBUG [4f4633f7] Command: ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-hybrazil-production-ronanlopes.sh" ; /usr/bin/env git ls-remote --heads git@[email protected]:fneto/hybrazil.git )

 DEBUG [4f4633f7]   Permission denied (publickey).

 DEBUG [4f4633f7]   

 DEBUG [4f4633f7]   fatal: Could not read from remote repository.

 DEBUG [4f4633f7]   

 DEBUG [4f4633f7]   

 DEBUG [4f4633f7]   Please make sure you have the correct access rights

 DEBUG [4f4633f7]   

and the repository exists.

 DEBUG [4f4633f7]   

On my production/deploy.rb, I have the config like this:

set :ssh_options, {
  keys: %w(/home/ronanlopes/Pems/hybrazil-impulso.pem ~/.ssh/id_rsa),
  forward_agent: true,
  auth_methods: %w(publickey)
}

any ideas? Thanks in advance!


Solution

  • You can add your key to agent, use command:

    ssh-add ~/.ssh/id_rsa
    

    In your code you should use full path to ssh key, without pem:

    keys: %w(/home/user_name/.ssh/id_rsa)