2016-12-31 57 views
1

我试图将我的rails应用程序从我的mac部署到数字海洋上的服务器上(使用github)。无法运行cap生产部署:使用Net :: SSH :: AuthenticationFailed初始化:身份验证用户失败?

所以,当我在firstime跑cap production deploy:initial我得到这个错误

** 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 deploy:set_rails_env (first_time) 
** Execute deploy:set_rails_env 
** Invoke rvm:hook (first_time) 
** Execute rvm:hook 

cap aborted! 
Net::SSH::AuthenticationFailed: Authentication failed for user [email protected] 

/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/net-ssh-4.0.0/lib/net/ssh.rb:250:in `start' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/connection_pool.rb:59:in `call' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/connection_pool.rb:59:in `with' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/netssh.rb:155:in `with_ssh' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/netssh.rb:108:in `execute_command' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `tap' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:55:in `test' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:21:in `block (3 levels) in <top (required)>' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:29:in `instance_exec' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/backends/abstract.rb:29:in `run' 
/Users/manjarb/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sshkit-1.11.5/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' 

但我已经添加了我的服务器id_rsa.pub到存储库部署的关键。 当我通过从ssh密钥克隆我的repo来测试时,它正常工作没有任何问题。

这是我所以deploy.rb

# config valid only for current version of Capistrano 
lock "3.7.1" 

set :repo_url,  '[email protected]:myrepo.git' 
set :application,  'appname' 
set :user,   'deploy' 
set :puma_threads, [4, 16] 
set :puma_workers, 0 

# Don't change these unless you know what you're doing 
set :pty,    true 
set :use_sudo,  false 
set :stage,   :production 
set :deploy_via,  :remote_cache 
set :deploy_to,  "/home/#{fetch(:user)}/apps/#{fetch(:application)}" 
set :puma_bind,  "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock" 
set :puma_state,  "#{shared_path}/tmp/pids/puma.state" 
set :puma_pid,  "#{shared_path}/tmp/pids/puma.pid" 
set :puma_access_log, "#{release_path}/log/puma.error.log" 
set :puma_error_log, "#{release_path}/log/puma.access.log" 
set :ssh_options,  { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) } 
set :puma_preload_app, true 
set :puma_worker_timeout, nil 
set :puma_init_active_record, true # Change to false when not using ActiveRecord 

namespace :puma do 
    desc 'Create Directories for Puma Pids and Socket' 
    task :make_dirs do 
    on roles(:app) do 
     execute "mkdir #{shared_path}/tmp/sockets -p" 
     execute "mkdir #{shared_path}/tmp/pids -p" 
    end 
    end 

    before :start, :make_dirs 
end 

namespace :deploy do 
    desc "Make sure local git is in sync with remote." 
    task :check_revision do 
    on roles(:app) do 
     unless `git rev-parse HEAD` == `git rev-parse origin/master` 
     puts "WARNING: HEAD is not the same as origin/master" 
     puts "Run `git push` to sync changes." 
     exit 
     end 
    end 
    end 

    desc 'Initial Deploy' 
    task :initial do 
    on roles(:app) do 
     before 'deploy:restart', 'puma:start' 
     invoke 'deploy' 
    end 
    end 

    desc 'Restart application' 
    task :restart do 
    on roles(:app), in: :sequence, wait: 5 do 
     invoke 'puma:restart' 
    end 
    end 

    before :starting,  :check_revision 
    after :finishing, :cleanup 
end 

我怎样才能解决这一问题?

谢谢!

回答

2

我不是一个红宝石或Capistrano的用户,但是:

set :ssh_options,  { ..., keys: %w(~/.ssh/id_rsa.pub) } 
              ^^^^^^^^^^ 

你应该在这里指定私钥文件,不公钥文件。私钥文件可能是“〜/ .ssh/id_rsa”,没有“.pub”扩展名。

相关问题