0

I have been trying to deploy a Rails app using Capistrano but when I run cap production deploy I get:

(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as 
deploy@12.34.56.789: Authentication failed for user deploy@12.34.56.789

Net::SSH::AuthenticationFailed: Authentication failed for user 
deploy@12.34.56.789

Tasks: TOP => rvm:check
(See full trace by running task with --trace)

I have tried to run cap production rvm:check --trace and I get this

** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke rvm:hook (first_time)
** Execute rvm:hook
** Invoke rvm:check (first_time)
** Execute rvm:check
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@12.34.56.789: Authentication failed for user deploy@12.34.56.789
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
Net::SSH::AuthenticationFailed: Authentication failed for user deploy@12.34.56.789
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/net-ssh-4.2.0/lib/net/ssh.rb:254:in `start'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/connection_pool.rb:59:in `call'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/connection_pool.rb:59:in `with'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/netssh.rb:174:in `with_ssh'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/netssh.rb:127:in `execute_command'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/abstract.rb:141:in `tap'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/abstract.rb:60:in `capture'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:9:in `block (3 levels) in <top (required)>'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/backends/abstract.rb:29:in `run'
/Users/k/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.14.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rvm:check

This is what my ssh part of deploy.rb looks like:

set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, 'ruby-2.3.1'
set :ssh_options, { forward_agent: true }
# set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/mykey.pem) }

I have this line in my config/deploy/production.rb

server "12.34.56.789", user: "deploy", roles: %w{app db web}, my_property: :my_value

When I run evalssh-agent`` and ssh-add ~/.ssh/id_rsa it works fine.

Am I missing anything here? How can I resolve this issue?

Thank you.

Kehinde
  • 11
  • 4
  • First of all check if this command succeed: ssh deploy@12.34.56.789 – Pavel S Nov 23 '17 at 11:44
  • It returns `Permission denied (publickey).` – Kehinde Nov 23 '17 at 15:43
  • I have not been able to get the `Permission denied (publicley).` resolved. I tried reading [Troubleshooting Connecting to Your Instance](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html#TroubleshootingInstancesConnectingMindTerm). – Kehinde Nov 24 '17 at 03:46
  • I was able to resolve it by checking that the public key was in the `authorized_keys`. It now works. Thanks – Kehinde Nov 24 '17 at 07:09

0 Answers0