Capistrano 3 deploy fails connecting to GitHub - Permission denied (publickey) Capistrano 3 deploy fails connecting to GitHub - Permission denied (publickey) symfony symfony

Capistrano 3 deploy fails connecting to GitHub - Permission denied (publickey)


Double-check that the user running Capistrano has ssh-agent running and has ssh-added the relevant key.

Here are some good guides:

https://developer.github.com/guides/using-ssh-agent-forwarding/

http://mah.everybody.org/docs/ssh


The solution to my problem was two things. Firstly I had to forward my id_rsa in the script like this:

set :ssh_options, {  user: 'ubuntu',  keys: ['~/.ssh/id_rsa'],  forward_agent: true,  auth_methods: ["publickey"]}

I put my id_rsa.pub key on the server so that I could ssh into the server with the same key as i was forwarding.

The second thing I had to do was set the permissions on /tmp using

chmod 1777 /tmp


I have faced similar issue during the cap run "$ bundle exec cap test deploy"

Error : git stdout: Nothing writtengit stderr: Warning: Permanently added the RSA host key for IP address 'xxxxxxxxx' to the list of known hosts.Permission denied (publickey).fatal: Could not read from remote repository.

For this scenario, we need to authenticate github account using ssh key

Navigate to the github -> Settings -> SSH and GPG keys (section) -> Add "New SSh Key", copy your public key($ ssh-keygen #generate new key)) and paste key input field. Once the key is added, using this command "$ ssh -T git@github.com" check the authentication. It will shows following output

Hi <xxxxxxxx>! You've successfully authenticated, but GitHub does not provide shell access.

Now It is working fine!.