Deploying with Capistrano 3 failing – Permission denied (publickey)

The problem:

Running cap production deploy was failing since it was not able to connect to Github.
The primary error generated was Permission denied (publickey), followed by fatal: The remote end hung up unexpectedly.

Solution:

There are many reasons which could cause this issue. In this case while troubleshooting the issue, running ssh-add generated a new error.

Google led me to this page https://coderwall.com/p/rdi_wq which provided the solution.

On the host (not the target) run

You should see the following output
Identity added: /Users/[user]/.ssh/id_rsa (/Users/[user]/.ssh/id_rsa)

I noticed that this fix is not permanent. Have to run ssh-add for new deployments.

PeteDeploying with Capistrano 3 failing – Permission denied (publickey)

Leave a Reply