Try to deploy rails app using Capistrano 3, when I run this command , get this error

vagrant@vagrant-ubuntu-utopic-32:/vagrant$ cap production deploy
INFO [e4213f70] Running /usr/bin/env mkdir -p /tmp/career/ on 192.168.51.54
DEBUG [e4213f70] Command: /usr/bin/env mkdir -p /tmp/career/
Text will be echoed in the clear. Please install the HighLine or Termios librari
es to suppress echoed text.
@192.168.51.54's password:secert
@192.168.51.54's password:secert
@192.168.51.54's password:secert
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 192.168.51.54: A
uthentication failed for user @192.168.51.54

Net::SSH::AuthenticationFailed: Authentication failed for user @192.168.51.54

Tasks: TOP => git:check => git:wrapper
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing on host 192.168.5
1.54: Authentication failed for user @192.168.51.54

i saw some posts [1,2]in stack overflow. but I am still getting error.

here is my Capfile:

require 'capistrano/setup'
set :stage, :production
require 'capistrano/deploy'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

deploy.rb file:

lock '3.4.0'
set :application, "career"
set :repo_url, "https://github.com/mezbahalam/offender_profile"

set :user, 'vagrant'
# set :scm_passphrase, "password"
set :deploy_to, "/home/vagrant/apps/career"
set :use_sudo, false
set :scm, :git
server "192.168.51.54",  roles: [:app, :web, :db], :primary => true 

what am I donig wrong?

2

There are 2 best solutions below

0
On BEST ANSWER

Try setting up ssh keys for deployment. Make sure that your public key is in the list of authorized keys on the server and that it is chmod 600.

0
On

In my case I just had to run below command:

ssh-add

and then try command cap production deploy again. and it worked well.