SSHKit::Runner::ExecuteError: Exception while executing on host Net::SSH::AuthenticationFailed: Authentication failed

SSHKit::Runner::ExecuteError: Exception while executing on host Net::SSH::AuthenticationFailed: Authentication failed

尝试使用 Capistrano 3 部署 rails 应用程序,当我 运行 这个命令时,得到这个错误

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

我在堆栈溢出中看到了一些帖子 [1,2]。但我仍然遇到错误。

这是我的 Capfile:

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

deploy.rb 文件:

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 

我做错了什么?

尝试设置用于部署的 ssh 密钥。确保您的 public 密钥在服务器上的授权密钥列表中并且它是 chmod 600。

在我的例子中,我只需要 运行 下面的命令:

ssh-add

然后再次尝试命令 cap production deploy。而且效果很好。