Capistrano:用户 ubuntu@xx.xxx.xxx.xxx 身份验证失败 (Net::SSH::AuthenticationFailed)

dr.*_*lix 4 capistrano ruby-on-rails

我可以通过 进行连接ssh ubuntu@xx.xxx.xxx.xxx。但不是通过cap production deploy:check

当前的

set :user, "ubuntu"
set :ssh_options, { forward_agent: true }

server "xx.xxx.xxx.xxx",
       user: fetch(:user),
       roles: %w[web app db]
Run Code Online (Sandbox Code Playgroud)

尝试过

set :user, "ubuntu"
set :ssh_options, {
  forward_agent: true,
  user: fetch(:user),
  keys: %w(~/.ssh/id_rsa)
}

server "xx.xxx.xxx.xxx",
       user: fetch(:user),
       roles: %w[web app db]
Run Code Online (Sandbox Code Playgroud)

“当前”曾经是我对其他项目的设置,我只需要ssh-add然后cap production deploy

发生了什么变化?或者我的配置不正确?

dr.*_*lix 16

问题:用户 ubuntu@xx.xxx.xxx.xxx (Net::SSH::AuthenticationFailed) 通过 capistrano 身份验证失败,但可以直接 ssh

调试:

  • sudo tail -f /var/log/auth.log在服务器上
  • cap production deploy:check然后在我本地尝试
  • userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]出现于auth.log

解决方案:

  • 然后编辑/etc/ssh/sshd_config
    • 找到PubkeyAuthentication然后取消注释(删除#
    • 添加PubkeyAcceptedKeyTypes=+ssh-rsa
  • 重新启动 sshdsudo systemctl restart sshd