fabdarice
fabdarice

Reputation: 895

Capistrano 3 - access denied to git repository on production server

I wanted to try the newer version of Capistrano 3 on a new project and have been struggling with this problem for a few days now.

while running "cap production deploy" for the first time, I always got the same error (LOG : http://pastebin.com/DKvzRTc2).

Apparently, it fails to run this command "git ls-remote [email protected]:......" on the server

I've tried everything : - forward_agent set as true with ssh key on local machine and uploaded on bitbucket - forward_agent set as false and uploaded manually the ssh key on the production server (when I run manually 'git [email protected]:......' on the server, it works perfectly.

I've already set the "user" attribute on the deploy.rb file, this doesn't fix the issue.

Thanks for the help, I'm open to any suggestion!

Upvotes: 0

Views: 796

Answers (2)

fabdarice
fabdarice

Reputation: 895

To those who has the same problem, my solution was to delete all the SSH keys from the ssh-agent (ssh-add -d path/to/all/keys) and then re-add your key (ssh-add yourkey).

I have no idea why but it seems that Capistrano 3 only consider the first key of your ssh-agent and use that key to access your git repository.

Hence, if your first key is not your project SSH key, then it will throw the exception error.

I didn't find any other way to fix it.

Upvotes: 3

Eric Cope
Eric Cope

Reputation: 877

I had a similar problem. It turned out it was trying to run scripts from /tmp. I did not have execute permissions in the /tmp directory. I added

set :tmp_dir, '/home/_user_home_dir/tmp'

to the staging.rb file.

It ran no problems.

Upvotes: 0

Related Questions