Capistrano 3在bitbucket上进行cap staging部署的Wordpress部署失败

时间:2014-02-02 13:47:41

标签: wordpress deployment staging capistrano3

我正在尝试为我的Wordpress设置进行Capistrano 3部署as per this screencast 我正在部署到ubuntu 12.04服务器

所以这是我的deploy.rb文件:

set :application, 'dladv'
set :repo_url, 'git@bitbucket.org:username/repo.git'

set :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

set :deploy_via, :copy
set :deploy_to, '/var/www/php/domain' # I have set the correct permissions with www:data group and added stager as member of this group

set :log_level, :debug
set :pty, true

set :linked_dirs, %w{uploads}

# set :default_env, {}


namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app) do
      sudo "apache2ctl", "graceful", "-v"
    end
  end

end

我的staging.rb看起来像这样:

set :stage, :staging

server 'staging.domain.com', user: 'stager', roles: %w{web app db}, port: 47

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

现在当我尝试cap staging deploy --trace时,我得到:

→ cap staging deploy --trace
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
 INFO [217d8451] Running /usr/bin/env mkdir -p /tmp/dladv/ on staging.domain.com
DEBUG [217d8451] Command: /usr/bin/env mkdir -p /tmp/dladv/
cap aborted!
Authentication failed for user stager@staging.domain.com
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/net-ssh-2.8.0/lib/net/ssh.rb:217:in `start'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/connection_pool.rb:25:in `create_or_reuse_connection'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:173:in `ssh'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:126:in `block in _execute'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/capistrano-3.0.1/lib/capistrano/tasks/git.rake:13:in `block (3 levels) in <top (required)>'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/amiterandole/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper
  1. 我已将imac的ssh/id_ra.pub密钥添加到服务器的authorized_keys文件中
  2. 我在服务器上生成了ssh-keygen -t rsa -C "myemail@gmail.com",然后将该密钥添加到我的github帐户和我的bitbucket帐户
  3. 我已使用ssh -T hg@bitbucket.org
  4. 在服务器上使用bitbucket进行了验证

    我不知道为什么一直说Authentication failed for user stager@staging.domain.com 请帮忙

1 个答案:

答案 0 :(得分:1)

试试这个:

set :user, 'your_deploy_user_name'

set :ssh_options, {
   user: fetch(:user)
}

这对我有用