Probably something simple, but I'm at wit's end after exploring everything i know of from the Cap docs and elsewhere.
I set up my `deploy.rb` like so:
```ruby
SSHKit.config.command_map[:rake] = "bundle exec rake" # Ensure that bundle is used for rake tasks
lock '3.1.0' # config valid only for Capistrano 3.1
set :application, '[myapp]'
set :user, "deploy"
set :deploy_to, '/var/www/[myapp]'
set :use_sudo, false
set :pty, false
set :keep_releases, 5
set :format, :pretty
set :log_level, :debug
set :repo_url, 'g...@github.com:....git'
set :scm, :git
set :branch, 'master'
set :ssh_options, { forward_agent: true }
...
```
My stage file for the `acceptance` stage looks like this:
```ruby
set :stage, :acceptance
set :node_env, 'test'
set :user, 'deploy'
user: 'deploy',
roles: %w{server_pipeline},
primary: true,
keys: ['~/.ssh/blah.pem']
```
With that, I get this result when I run `cap acceptance deploy`:
DEBUG [a824cd7c] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/[myapp]/git-ssh.sh /usr/bin/env git ls-remote g...@github.com:....git )
DEBUG [a824cd7c] Permission denied (publickey).
DEBUG [a824cd7c] fatal: Could not read from remote repository.
DEBUG [a824cd7c]
DEBUG [a824cd7c] Please make sure you have the correct access rights
DEBUG [a824cd7c] and the repository exists.
DEBUG [a824cd7c] Finished in 0.175 seconds with exit status 128 (failed).
The maddening thing is that I can copy the command on the second output line above verbatim and run it from the command line on my server and it works fine. I reread the Cap page about things working via SSH but not when run by Cap, but couldn't see anything there to explain the result I'm getting. Here's what else I checked:
- I confirmed that I followed all instructions from *Authentication & Authorisation* followed, the deploy user exists, and all dirs exist with the correct permissions
- The ssh agent on the target box is running, and my key is loaded
- I set up no-password access for the `deploy` user
- I can run `git ls-remote` from the box and get a response from GitHub
- `ssh -vT g...@github.com` confirms I can connect
So I'm stumped. Don't know what else to try. Can anyone suggest something else to check/change? SSH issues can be so frustrating.