遇到一台服务器,明明设置了免密登录,通过私钥登录的时候还是提示需要输入用户密码才能登录 ,
一、检查/etc/ssh/sshd_config
PubkeyAuthentication yes # 启用公告密钥配对认证方式
RSAAuthentication yes # 允许RSA密钥
PasswordAuthentication no # 禁止密码验证登录
PermitRootLogin no # 禁用root账户登录
二、用户目录.ssh(700),authorized_keys(600)
三、以上检查没问题,还是需要输入密码才能登录
1、检查/var/log/auth.log 发现如下登录日志
userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
2、 经过检查得知open-ssh版本太高导致的
root@localhost:/var/log# ssh -V
OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022
3、解决方法:
如果重启失败,删除添加的这行重新操作一边即可
echo "PubkeyAcceptedKeyTypes=+ssh-rsa" >>/etc/ssh/sshd_config
/etc/init.d/ssh restart