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.
$ 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
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 /
By doing this, I was able to save the ssh key and successfully deploy it!
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.