简体   繁体   English

重启服务器实例后,Capistrano 抛出 Authentication failed for user Net::SSH::AuthenticationFailed 错误

[英]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.经过一番谷歌搜索,我尝试了以下步骤,但没有成功。

  1. Added my public key(.ssh/id_rsa.pub) to authorized_keys of target server将我的公钥(.ssh/id_rsa.pub)添加到目标服务器的authorized_keys
  2. Allowing my IP address to the inbound rule of server.允许我的 IP 地址进入服务器的入站规则。
  3. Tried to put only the server key in my ssh-agent.试图只将服务器密钥放在我的 ssh-agent 中。

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-rsa PubkeyAcceptedKeyTypes=+ssh-rsa

Restart the sshd to reflect the changes重新启动sshd以反映更改

sudo systemctl restart sshd sudo systemctl 重启 sshd

Reference参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Capistrano 3.5 Net :: SSH :: AuthenticationFailed:验证失败 - Capistrano 3.5 Net::SSH::AuthenticationFailed: Authentication failed Net::SSH::AuthenticationFailed:用户身份验证失败 - Net::SSH::AuthenticationFailed: Authentication failed for user Capistrano无法部署代码,因为Net :: SSH :: AuthenticationFailed:验证失败 - Capistrano cannot deploy code, because Net::SSH::AuthenticationFailed: Authentication failed Capistrano:用户 ubuntu@xx.xxx.xxx.xxx 的身份验证失败(Net::SSH::AuthenticationFailed) - Capistrano: Authentication failed for user ubuntu@xx.xxx.xxx.xxx (Net::SSH::AuthenticationFailed) Capistrano Net :: SSH :: AuthenticationFailed - Capistrano Net::SSH::AuthenticationFailed Capistrano-Net :: SSH :: AuthenticationFailed - Capistrano - Net::SSH::AuthenticationFailed cap production deploy error Net :: SSH :: AuthenticationFailed:身份验证失败 - cap production deploy error Net::SSH::AuthenticationFailed: Authentication failed 无法使用Net :: SSH :: AuthenticationFailed运行cap production deploy:initialed:用户身份验证失败? - Cannot run cap production deploy:initial with Net::SSH::AuthenticationFailed: Authentication failed for user? 使用capistrano部署时,Net :: SSH :: AuthenticationFailed - Net::SSH::AuthenticationFailed when deploying with capistrano Rails 4 + Capistrano + AWS Net :: SSH :: AuthenticationFailed:部署 - Rails 4 + Capistrano + AWS Net::SSH::AuthenticationFailed: deploy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM