[RUBY] What to do if an SSH key authentication error occurs during automatic deployment to EC2 with Capistrano

To share

I'm developing in Rails and used Capistrano to implement automatic deployment to AWS. Suddenly, I got an SSH key authentication error and couldn't deploy, so Easily share the solution.

error contents

$ bundle exec cap production deploy

When executing the deployment with, the following error occurred.

SSHKit::Runner::ExecuteError: Exception while executing as ec2-user@ElasticIP: Authentication failed for user ec2-user@ElasticIP

solution

It seems that the ssh key disappears when the terminal is restarted, so I had to re-register by doing the following.

Local to the terminal

$ eval \`ssh-agent `

$ ssh-add -K ~ / .ssh / .pem

By doing this, I was able to save the ssh key and successfully deploy it!

company introduction

I am currently working for a logistics x IT company called Dialog Co., Ltd.. As of October 2020, we are not recruiting engineers, but we are looking for various other occupations, so please visit the Wantedly page. Please look.

Recommended Posts

What to do if an SSH key authentication error occurs during automatic deployment to EC2 with Capistrano
What to do if you get an error in Basic authentication during Rails test code
What to do if changes are not reflected after automatic deployment to EC2
What to do if you get an error during rails db: reset
What to do if an error occurs when nokogiri enters when bundle install
no space left on device What to do if an error occurs
What to do if you should have installed Rails but an error occurs with rails -v (for beginners)
wildflly10 java8 ERROR [org.jboss.jca.core.tx.jbossts.XAResourceRecoveryImpl] (Periodic Recovery) IJ000906 What to do if an error occurs
[Rails] What to do if you can't get an error message with the errors method
What to do if an error occurs when doing npm install axios in React + Typescript project
What to do if you get an uninitialized constant Likes Controller error
What to do and how to install when an error occurs in DXRuby 1.4.7
What to do if you get an error when you hit Heroku logs
After installing'devise''bootstrap' of gemfile with rails, what to do when url is an error
What to do if ClassNotFoundException occurs when starting Tomcat
What to do when a null byte error occurs
What to do if you get the error Couldn't find Item without an ID
Error ExecJS :: RuntimeUnavailable: What to do when it occurs
What to do if password authentication fails in Docker/Postgres
What to do if a SAX Parser error occurs when using Liferay 7 / DXP on AWS
What to do when you launch an application with rails
I tried automatic deployment with CircleCI + Capistrano + AWS (EC2) + Rails
What to do if mysql2 gets a bundle install error
For beginners! Automatic deployment with Rails6 + CircleCI + Capistrano + AWS (EC2)
Notes on what to do if Ubuntu 20.04 installation on Virtual box 6.1 (Windows10) fails with "Error 5 Input / output error"
[Spring Boot] What to do if an HttpMediaTypeNotAcceptableException occurs on an endpoint for which produces is set
What to do if you get an [An HTTP request took too long to complete.] Error in Docker.
What to do when an UnsupportedCharsetException occurs in a lightweight JRE
What to do if you get a gcc error in Docker
What to do if you get a DISPLAY error in gym.render ()
What to do if you get angry with OpenSSL with pyenv install
[Logback] What to do if unnecessary files do not disappear during rotation
[Rails] What to do if you can't get parameters with form_with
Automatic file upload with old Ruby gem What to do with Watir
What to do if an error occurs in VS Code when importing a django module or your own module installed by pip install
Deploy to EC2 with CircleCi + Capistrano
What to do if zip dies if there is a pom when making an executable jar with gradle
What to do when javax.batch.operations.JobStartException occurs
What to do if you get the error Too long with no output (exceeded 10m0s) on CircleCI
What to do if JavaMail cannot be used with OpenJDK 11 or later
What to do if the background image is not applied after deployment
What to do if deployment fails on Heroku (Ruby app not detected)
Notes on what to do when EC2 is set up with t2.micro
How to SSH into Ubuntu from a terminal with public key authentication
What to do if the build fails with the error "Module compiled with Swift x.x.x cannot be imported by the Swift x.x.x compiler"
What to do if you get an "A server is already running." Error when you try to start the rails server
Connect to Amazon EC2 with SSH (Ubuntu)
Easy deployment with Capistrano + AWS (EC2) + Rails
What to do when a javax.el.PropertyNotWritableException occurs
What to do if you install Ubuntu
What to do if you get the error message unrecognized selector send to instance "***"
[Error resolution] Occurs when trying to build an environment for spring with docker
What to do if ffi installation fails when launching an application in Rails
[Java] What to do if you get an error in Eclipse saying "Not allowed at source level below 1.X"
What to do if you get an Argument Error: wrong number of arguments (given 2, expected 0) in your RSpec test
[Rails] What to do when you want to generate an error that cannot be destory when foreign key restrictions are applied
What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server