ruby on rails - Authentication failed Error when deploying to AWS EC2 AMI with Capistrano -


i following tutorial:

https://www.sitepoint.com/deploy-your-rails-app-to-aws/ 

the app created , running in development (including database). keys have been added git , ssh, although tutorial sure of them goes where.

and error getting.

$ gem list net  *** local gems ***  net-http-digest_auth (1.4) net-http-persistent (2.9.4) net-scp (1.2.1) net-ssh (3.2.0, 3.1.1) net-telnet (0.1.1) contactbook liviu-mac $ cap production deploy --trace ** invoke production (first_time) ** execute production ** invoke load:defaults (first_time) ** execute load:defaults ** invoke rvm:hook (first_time) ** execute rvm:hook ** invoke rvm:check (first_time) ** execute rvm:check cap aborted! net::ssh::authenticationfailed: authentication failed user deploy@52.87.233.215 /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/net-ssh-3.2.0/lib/net/ssh.rb:249:in `start' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/connection_pool.rb:59:in `call' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/connection_pool.rb:59:in `with' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/netssh.rb:155:in `with_ssh' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/netssh.rb:108:in `execute_command' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:141:in `tap' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:60:in `capture' /users/liviu-mac/.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/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:29:in `instance_exec' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/backends/abstract.rb:29:in `run' /users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.3/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' tasks: top => rvm:check 

i attempted fixes suggested in posts found. nothing works me.

here more details:

$ gem list net  *** local gems ***  net-http-digest_auth (1.4) net-http-persistent (2.9.4) net-scp (1.2.1) net-ssh (3.2.0, 3.1.1) net-telnet (0.1.1) 

my capfile is:

# load dsl , set stages require "capistrano/setup"  # include default deployment tasks require "capistrano/deploy"  require 'capistrano/rvm' # require 'capistrano/rbenv' # require 'capistrano/chruby' require 'capistrano/bundler' require 'capistrano/rails/assets' require 'capistrano/rails/migrations' require 'capistrano/puma' # require 'capistrano/passenger' require 'capistrano/ssh_doctor'  # load custom tasks `lib/capistrano/tasks` if have defined dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } 

my config/deply/production.rb file (one single uncommented line):

server '52.87.233.215', user: 'deploy', roles: %w{web app db} 

and config/deploy.rb file is:

# config valid current version of capistrano lock '3.6.1'  set :application, 'contactbook' set :repo_url, 'git@github.com:levi-l-damian/contactbook.git'  # default branch :master # ask :branch, `git rev-parse --abbrev-ref head`.chomp set :branch, :master  # default deploy_to directory /var/www/my_app_name # set :deploy_to, '/var/www/my_app_name' set :deploy_to, '/home/deploy/contactbook'  # default value :pty false set :pty, true  # default value :linked_files [] # append :linked_files, 'config/database.yml', 'config/secrets.yml' set :linked_files, %w{config/database.yml config/application.yml}  # default value linked_dirs [] # append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system' set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}  # default value keep_releases 5 set :keep_releases, 5  set :rvm_type, :user set :rvm_ruby_version, 'ruby-2.3.1' # edit if using mri ruby  set :puma_rackup, -> { file.join(current_path, 'config.ru') } set :puma_state, "#{shared_path}/tmp/pids/puma.state" set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"    #accept array multi-bind set :puma_conf, "#{shared_path}/puma.rb" set :puma_access_log, "#{shared_path}/log/puma_error.log" set :puma_error_log, "#{shared_path}/log/puma_access.log" set :puma_role, :app set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production')) set :puma_threads, [0, 8] set :puma_workers, 0 set :puma_worker_timeout, nil set :puma_init_active_record, true set :puma_preload_app, false 

don't know how fix , move forward?

when troubleshooting authentication failed errors in capistrano, useful drop down lower level , test connectivity ssh first. way can figure out if capistrano problem, or more basic ssh connectivity issue.

in case capistrano says cannot connect 52.87.233.215 deploy user. let's verify manually this:

ssh -v deploy@52.87.233.215 

the -v flag dumps bunch of verbose logging can see authentication methods being attempted.

if permission denied (publickey), indication not have public key installed on server. in other words, server has no way of verifying claim be, , denies access.

to install public key, copy contents of file from local machine:

~/.ssh/id_rsa.pub 

and paste contents file on server:

~deploy/.ssh/authorized_keys 

make sure ~deploy/.ssh/authorized_keys owned , accessible deploy user:

$ ls -ld ~deploy/.ssh drwxr-xr-x 2 deploy deploy 4096 jun 16  2015 /home/deploy/.ssh $ ls -ld ~deploy/.ssh/authorized_keys -rw------- 1 deploy deploy 1023 sep 12 02:13 /home/deploy/.ssh/authorized_keys 

now try ssh command again:

ssh -v deploy@52.87.233.215 

it should work, , if so, capistrano should work well.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -