I first deployed using git clone in /var/www/AppName directory and was able to successfully deploy it. I then tried using capistrano and link it with my git. I am following this Link to deploy app using capistrano. I am facing authentication issues.
My deploy.rb file is
set :application, 'blog'set :repo_url, 'git@github.com:abc@def.com/blog.git'set :branch, 'master'set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads')set :rvm_ruby_version, '2.6.5'set :passenger_restart_with_touch, trueset :deploy_to, '/var/www/blog'set :use_sudo, true
and production.rb is
role :app, %w[deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com]role :web, %w[deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com]role :db, %w[deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com]set :ssh_options, { keys: %w[/d/Manna/Learning/RoR/EC2-Ubuntu.pem], forward_agent: true, user: 'deploy_user', auth_methods: %w[publickey password]}
However, I am facing issues in authentication of deploy_user on EC2. I am able to SSH into EC2 using pem key. Here is the output when i try using "cap production deploy --trace"
** Invoke production (first_time) ** Execute production ** Invoke load:defaults (first_time) ** Execute load:defaults ** Invoke rvm:hook (first_time) ** Invoke passenger:rvm:hook (first_time) ** Invoke passenger:test_which_passenger (first_time) ** Execute passenger:test_which_passenger deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com's password:
run> terminated with exception (report_on_exception is true): Traceback (most recent call last): 12: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:12:in
block (2 levels) in execute' 11: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in
run' 10: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:ininstance_exec' 9: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capistrano-passenger-0.2.0/lib/capistrano/tasks/passenger.cap:42:in
block (3 levels) in ' 8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:61:intest' 7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in
create_command_and_execute' 6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:intap' 5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in
block in create_command_and_execute' 4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/netssh.rb:130:inexecute_command' 3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/netssh.rb:177:in
with_ssh' 2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/connection_pool.rb:63:inwith' 1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/connection_pool.rb:63:in
call' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-6.0.0/lib/net/ssh.rb:268:instart': Authentication failed for user deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com (Net::SSH::AuthenticationFailed) 1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:in
block (2 levels) in execute' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:inrescue in block (2 levels) in execute': Exception while executing as deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com: Authentication failed for user deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com (SSHKit::Runner::ExecuteError) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com: Authentication failed for user deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:in
rescue in block (2 levels) in execute' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:inblock (2 levels) in execute' Caused by: Net::SSH::AuthenticationFailed: Authentication failed for user deploy_user@ec2-13-232-140-179.ap-south-1.compute.amazonaws.com C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-6.0.0/lib/net/ssh.rb:268:in
start' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/connection_pool.rb:63:incall' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/connection_pool.rb:63:in
with' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/netssh.rb:177:inwith_ssh' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/netssh.rb:130:in
execute_command' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:inblock in create_command_and_execute' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in
tap' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:increate_command_and_execute' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:61:in
test' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capistrano-passenger-0.2.0/lib/capistrano/tasks/passenger.cap:42:inblock (3 levels) in <top (required)>' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in
instance_exec' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:inrun' C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:12:in
block (2 levels) in execute' Tasks: TOP => rvm:hook => passenger:rvm:hook => passenger:test_which_passenger