I'm implementing automatic deployment on Capistrano, but it stops when I log in to EC2.

Error log

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 [email protected] 91.188: Authentication failed for user [email protected] (SSHKit :: Runner :: ExecuteError)
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit :: Runner :: ExecuteError: Exception while executing as [email protected]: Authentication failed for user [email protected]
Caused by:
Net :: SSH :: AuthenticationFailed: Authentication failed for user [email protected]
Tasks: TOP =>rbenv: validate


server "", user: "ec2-user", roles:% w {web app}


# config valid for current version and patch releases of Capistrano
lock "~>3.14.1"
set: application, "conefan"
set: repo_url, "[email protected]: 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 Command executor's private key
  port: 22, 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'

What I tried

  • Restart EC2, Nginx, Mysql
  • Copy the private key to ~/.ssh in the container and grant permissions at 600 (grant 700 to ~/.ssh)
  • After attaching to the container, confirm that you can log in with $ssh -i ~/.ssh/[email protected]

There are few reference articles for capistrano automatic deployment using Docker in the development environment, and we are struggling.
Thanks for your cooperation.