Net::SSH::AuthenticationFailed エラーでEC2へのデプロイに失敗する
この度、Railsで作成したアプリを、Capistrano3.4でEC2にデプロイしたいのですが、下記コマンドを実行後、エラーが発生してしまいデプロイができません。
環境
- EC2
- Rails4
- Unicorn
- Nginx
- Capistrano3
実行したコマンド
[ec2-user@ip-172-31-30-10 ec2_test_app]$ pwd
/var/www/ec2_test_app/ec2_test_app
[ec2-user@ip-172-31-30-10 ec2_test_app]$ bundle exec cap production deploy
エラー文
(Backtrace restricted to imported tasks)
cap aborted!
Net::SSH::AuthenticationFailed: Authentication failed for user ec2-user@32.826.472.663
Tasks: TOP => rbenv:validate
(See full trace by running task with --trace)
デプロイで参考にしたサイト
http://qiita.com/SanoHiroshi/items/d7942d66678f0d60f0ed
設定ファイル等
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
}
http {
root /var/www/ec2_test_app/current;
upstream unicorn-server {
server unix:/var/www/ec2_test_app/shared/tmp/sockets/unicorn.sock
fail_timeout=0;
}
server {
listen 80;
client_max_body_size 4G;
server_name 32.826.472.663;
keepalive_timeout 80;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /var/www/ec2_test_app/current;
location ~ ^/assets/ {
include /etc/nginx/mime.types;
root /var/www/ec2_test_app/current/public;
}
location / {
proxy_pass http://unicorn-server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/ec2_test_app/current/public;
}
}
}
Gemfile
group :production, :staging do
gem 'unicorn'
end
group :development do
gem 'capistrano', '~> 3.4'
gem 'capistrano-rails', '~> 1.1', require: false
gem 'capistrano-bundler', '~> 1.1', require: false
gem 'capistrano-rbenv', '~> 2.0', require: false
gem 'capistrano3-unicorn'
end
Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/rbenv'
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
config/deploy.rb
set :application, 'ec2_test_app'
set :repo_url, 'git@github.com:hoge-fuga/ec2_test_app.git'
set :branch, 'master'
set :deploy_to, '/var/www/ec2_test_app/ec2_test_app'
set :keep_releases, 5
set :rbenv_type, :user
set :rbenv_ruby, '2.3.0'
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all
set :linked_dirs, %w{bin log tmp/backup tmp/pids tmp/cache tmp/sockets vendor/bundle}
after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
task :restart do
invoke 'unicorn:restart'
end
end
config/unicorn.rb
application = 'reserve-hacker'
worker_processes 2
app_path = "/var/www/ec2_test_app/ec2_test_app"
listen "#{app_path}/shared/tmp/sockets/unicorn.sock"
pid "#{app_path}/current/tmp/unicorn.pid"
timeout 60
preload_app true
stdout_path "#{app_path}/current/log/production.log"
stderr_path "#{app_path}/current/log/production.log"
GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
config/deploy/production.rb
set :stage, :production
set :rails_env, 'production'
server '32.826.472.663', user: 'ec2-user',
roles: %w{web app db}
set :ssh_options, {
keys: [File.expand_path('~/.ssh/id_rsa.pem)')]
}
エラーが発生して、デプロイできない原因をアドバイス頂きたいです。
また、今まで見れていたNginxの画面が、下記URLを叩いても404 Not Foundが表示されて、急に見れなくなってしまいました。
http://192.0.2.100 (数字は適当)
こちらも原因をアドバイス頂きたいです。
何卒宜しくお願い致します。