我一直在尝试使用Capistrano部署Rails应用程序但是当我运行cap production deploy
时,我得到了:
(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)
我试图运行cap production rvm:check --trace
而我得到了这个
** 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
这是deploy.rb
的ssh部分:
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) }
我在config/deploy/production.rb
server "12.34.56.789", user: "deploy", roles: %w{app db web}, my_property: :my_value
当我运行eval
ssh-agent``和ssh-add ~/.ssh/id_rsa
时,它运行正常。
我在这里遗漏了什么?我该如何解决这个问题?
谢谢。
答案 0 :(得分:0)
我有一个类似的问题。该答案总结了@PavelS和@Kehinde的上述评论,并使其更普遍适用:
请确保您可以ssh
使用日志文件或stderr中的凭据。在这个问题中,这必须起作用:ssh deploy@12.34.56.789
。如果这不起作用,则可能有多种原因。
在OP的情况下,他显然需要启用ssh
,如此处详细说明:不使用密码的SSH登录:{{3 }}。
在我的情况下,我们用于部署的一台服务器已关闭,并且部署代码使用了此无法正常运行的服务器。因此ssh
显然不起作用,但是原因有所不同。我将代码更改为使用备用的有效部署服务器,对此有效:ssh deploy@another.server.that.works
。