![](/img/trans.png)
[英]Cannot run cap production deploy:initial with Net::SSH::AuthenticationFailed: Authentication failed for user?
[英]cap production deploy error Net::SSH::AuthenticationFailed: Authentication failed
http://www.sitepoint.com/deploy-your-rails-app-to-aws/
我正在按照本教程將我的Rails應用程序部署到Amazon EC2,直到我告訴我這樣做:
cap production deploy
當我在我的代碼所在的文件夾中鍵入它時,我收到此錯誤:
** 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
DEBUG [be2a201f] Running ~/.rvm/bin/rvm version as deploy@54.152.90.79
DEBUG [be2a201f] Command: ~/.rvm/bin/rvm version
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@54.152.90.79: Authentication failed for user deploy@54.152.90.79
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Net::SSH::AuthenticationFailed: Authentication failed for user deploy@54.152.90.79
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/net-ssh-3.0.1/lib/net/ssh.rb:239:in `start'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/connection_pool.rb:50:in `call'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/connection_pool.rb:50:in `create_new_entry'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/connection_pool.rb:22:in `checkout'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:187:in `with_ssh'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:137:in `block in _execute'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `tap'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `_execute'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:77:in `capture'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:9:in `block (3 levels) in <top (required)>'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/Minling/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
我想我正確地遵循了教程中的所有內容。 這是我第一次使用EC2,我應該如何解決這個問題?
這是我的deploy.rb文件
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'studentdiscount'
set :repo_url, 'git@github.com:minling/StudentDiscount.git'
set :branch, :master
set :deploy_to, '/home/deploy/studentdiscount'
set :pty, true
set :linked_files, %w{config/database.yml config/application.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, 'jruby-1.7.19' # Edit this if you are using MRI Ruby
set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock" #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 8]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, false
set :ssh_options, { user: 'deploy', keys: %w(~/.ssh/student-discount-ec2.pem), forward_agent: true }
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, '/var/www/my_app_name'
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
有一部分我有點困惑:(但不是我認為錯誤的原因,因為我有這個問題,因為身份驗證錯誤?)
set :rvm_ruby_version, 'jruby-1.7.19' # Edit this if you are using MRI Ruby
我不是在使用jruby,我應該把它放在那里呢? 我如何找到MRI版本?
我有同樣的錯誤。 我解決了這個問題:
ssh-add ~/.ssh/student-discount-ec2.pem
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.