[英]After restarting the server instance, Capistrano throws the error that Authentication failed for user Net::SSH::AuthenticationFailed
It is our maintenance project.这是我们的维护项目。 We have got the private key( id_rsa.txt ) of production server to sign-in from the client.
我们已经获得了生产服务器的私钥( id_rsa.txt ),可以从客户端登录。
If we want to deploy the application, we just add the private key file to my local ssh-agent如果我们要部署应用程序,我们只需将私钥文件添加到我的本地 ssh-agent
ssh-add id_rsa.txt
ssh-添加 id_rsa.txt
then follow the capistrano's deployment command and got success然后按照capistrano的部署命令就成功了
bundle exec cap deploy
捆绑执行帽部署
Here is the line for ssh in Deploy.rb:这是 Deploy.rb 中的 ssh 行:
server 'example.com', user: 'app', roles: %w[app db web sidekiq]
set :ssh_options, { forward_agent: true, user: "app", keys: %w(/home/user/id_rsa.txt) }
Problem: Everything was fine before the instance restarted via aws's web console.问题:在实例通过 aws 的 Web 控制台重新启动之前一切正常。 After, we are unable to deploy and getting an error as
之后,我们无法部署并收到错误消息
home/rubx/.rvm/gems/ruby-2.7.2@glamz-web/gems/net-ssh-6.1.0/lib/net/ssh.rb:268:in `start': Authentication failed for user user@example.com (Net::SSH::AuthenticationFailed)
1: from /home/rubx/.rvm/gems/ruby-2.7.2@glamz-web/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/home/rubx/.rvm/gems/ruby-2.7.2@glamz-web/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as app@52.58.220.92: Authentication failed for user user@example.com (SSHKit::Runner::ExecuteError)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as user@example.com: Authentication failed for user user@example.com
/home/rubx/.rvm/gems/ruby-2.7.2@glamz-web/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/home/rubx/.rvm/gems/ruby-2.7.2@glamz-web/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
Caused by:
Net::SSH::AuthenticationFailed: Authentication failed for user user@example.com
After some googling, I tried the following steps but did not succeed.经过一番谷歌搜索,我尝试了以下步骤,但没有成功。
Note: We can successfully login to server using the same key file注意:我们可以使用相同的密钥文件成功登录服务器
Do I need to configure the server specifically for Capistrano deployment?我是否需要专门为 Capistrano 部署配置服务器? Thanks in advance
提前致谢
We were trying syslog(/var/log/syslog) for the log messages and then some googling came to know about the /var/log/auth.log.我们正在尝试使用 syslog(/var/log/syslog) 来获取日志消息,然后通过谷歌搜索了解了 /var/log/auth.log。 The following error messages were found on auth.log while establishing a server connection via the script
通过脚本建立服务器连接时,在 auth.log 上发现以下错误消息
Jun 11 05:01:36 ip- sshd[1757827]: userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
Jun 11 05:01:36 ip- sshd[1757827]: Connection closed by authenticating user app 15.4.81.22 port 47652 [preauth]
Solution解决方案
The problem was solved after allowing the ssh-rsa algorithm to PubkeyAcceptedKeyTypes in the sshd configuration sshd配置中允许ssh-rsa算法PubkeyAcceptedKeyTypes后问题解决
sudo vi /etc/ssh/sshd_config
须藤 vi /etc/ssh/sshd_config
PubkeyAcceptedKeyTypes=+ssh-rsaPubkeyAcceptedKeyTypes=+ssh-rsa
Restart the sshd to reflect the changes重新启动sshd以反映更改
sudo systemctl restart sshd
sudo systemctl 重启 sshd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.