Capistranoで自動デプロイを実装しているのですが、EC2にログインするところで止まってしまいます。
エラーログ
1: from /usr/local/bundle/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute' /usr/local/bundle/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as ec2-user@18.178.91.188: Authentication failed for user ec2-user@18.178.91.188 (SSHKit::Runner::ExecuteError) (Backtrace restricted to imported tasks) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as ec2-user@18.178.91.188: Authentication failed for user ec2-user@18.178.91.188 Caused by: Net::SSH::AuthenticationFailed: Authentication failed for user ec2-user@18.178.91.188 Tasks: TOP => rbenv:validate
config/deploy/production.rb
server "18.178.91.188", user: "ec2-user", roles: %w{web app}
config/deploy.rb
# config valid for current version and patch releases of Capistrano lock "~> 3.14.1" set :application, "conefan" set :repo_url, "git@github.com:shun0211/live_share.git" # 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/rails/live_share" # Default value for :format is :airbrussh. # set :format, :airbrussh # You can configure the Airbrussh format using :format_options. # These are the defaults. # set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto # Default value for :pty is false # set :pty, true # Default value for :linked_files is [] # append :linked_files, "config/database.yml" # Default value for linked_dirs is [] # append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system" # Default value for default_env is {} # set :default_env, { path: "/opt/ruby/bin:$PATH" } # Default value for local_user is ENV['USER'] # set :local_user, -> { `git config user.name`.chomp } # Default value for keep_releases is 5 set :keep_releases, 5 # Uncomment the following to require manually verifying the host key before first deploy. # set :ssh_options, { keys: %w(/root/.ssh/live_share_key_rsa), forward_agent: true, auth_methods: %w(publickey) } set :ssh_options, { # capistranoコマンド実行者の秘密鍵 port: 22, keys: %w(~/.ssh/live_share_key_rsa), forward_agent: false, auth_methods: %w(publickey) } # set :ssh_options, auth_methods: ['publickey'], # keys: ['/root/.ssh/live_share_key_rsa'] set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads') set :rbenv_type, :user set :rbenv_ruby, '2.7.1' set :unicorn_pid, -> { "#{shared_path}/tmp/pids/unicorn.pid" } set :unicorn_config_path, -> { "#{current_path}/config/unicorn.conf.rb" } after 'deploy:publishing', 'deploy:restart' namespace :deploy do task :restart do invoke 'unicorn:restart' end end
試したこと
- EC2、Nginx、Mysqlの再起動
- コンテナ内の~/.sshに秘密鍵をコピーし、権限を600で付与(~/.sshに700を付与)
- コンテナにアタッチ後、$ ssh -i ~/.ssh/<秘密鍵> ec2-user@18.178.91.188ではログインできることを確認
開発環境にDockerを使ったcapistrano自動デプロイの参考記事が少なく苦戦しております。
何卒よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。