使用Capistrano版本3进行身份验证失败:用户@ xxxxxxxxx的身份验证失败

时间:2014-08-21 20:10:17

标签: ruby-on-rails capistrano

我第一次尝试部署我的应用程序,所有内容似乎都很好,直到Capistrano到达我的:db变量并且由于对名为deployer的用户的身份验证失败而中断。部署员由我和我的团队成员共享。

我仔细阅读了wiki,并按照Capistrano关于准备我的应用程序和身份验证/授权的文档进行了操作,但是在git包装器的身份验证级别仍然出现了问题。这是我收到的错误:

   INFO[0d3fe580] Running /usr/bin/env mkdir -p /tmp/openhub/ on deployer
DEBUG[0d3fe580] Command: /usr/bin/env mkdir -p /tmp/openhub/
INFO[610db5a4] Running /usr/bin/env mkdir -p /tmp/openhub/ on testing-crawl-1
DEBUG[610db5a4] Command: /usr/bin/env mkdir -p /tmp/openhub/
cap aborted!
Exception while executing on host testing-crawl-1: Authentication failed for user @testing-crawl-1
/var/lib/gems/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh.rb:219:in `start'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/connection_pool.rb:50:in `call'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/connection_pool.rb:50:in `create_new_entry'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/connection_pool.rb:22:in `checkout'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:179:in `with_ssh'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/var/lib/gems/1.9.1/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:17:in `block (3 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/var/lib/gems/1.9.1/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper
(See full trace by running task with --trace)

这是我推断的内容。对于这一行确定的github,身份验证似乎失败了:

/var/lib/gems/1.9.1/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:17:

这是我尝试过的。

  • 我尝试了Cap Authentication/Authorization tutorial
  • 我已经确认我部署的(machine-utility-1)机器具有相同的功能 ssh密钥配对作为test-crawling-1和testing-web-1(我最终部署的服务器)
  • 我已经阅读了很多有关失败的wiki,包括此stackoverflow回答git.rake
  • 我在deploy.rb和testing.rb中尝试了一些配置选项,我将在下面展示

Deploy.rb:

role :app, %w{testing-web-1}
role :web, %w{testing-web-1}
role :db, %w{testing-crawl-1}, primary: true}
role :user, 'deployer'
role :slave, "testing-crawl-1"
role :memcache, 'testing-web-1', no_release: true
set :stage, :testing
set :rails_env, :testing

server 'testing-web-1', user: 'deployer', roles: %w{web app}, primary: true

set :ssh_options, {
#    keys: %w(/home/rlisowski/.ssh/id_rsa),
forward_agent: true
#auth_methods: %w(password)
}

我试图更改键参数以指向我的/home/deployer/.ssh/id_rsa 我试过设置auth_methods:到%w(public_key)

最后,我的config / testing.rb

lock '3.2.1'
set :application, 'openhub'
set :repo_url, 'git@github.com:blackducksw/ohloh.git'
set :default_stage, 'testing'
set :use_sudo, false

set :deploy_to, "/var/local/#{fetch(:application)}"
set :pty, true
set :linked_files, %w{config/database.yml}
set :deploy_via, :remote_cache

我不知所措。我不确定为什么身份验证会失败并且我没有采取行动。任何帮助,将不胜感激。感谢。

1 个答案:

答案 0 :(得分:1)

如果您仍然遇到问题,可以尝试使用capistrano-ssh-doctor gem。它用于调试capistrano ssh连接和问题就像这个。