SSH报错Unable to authenticate | version mismatch

错误一:Unable to authenticate

The client has disconnected from the server. Reason:Unable to authenticate using any of the configured authentication methods.

意思是无法进行身份验证,这个错误信息比较模糊,无法马上确定,排查可能是以下原因导致:

  1. SSH客户端没有开启密码验证

  2. 或者SSH服务端不允许密码验证

  3. 也有可能是SSH Keys错误(丢失/损坏/不匹配)

换用Terminal SSH连接

这么做是因为我之前一直是用SecureCRT正常连接的,最近才开始报这个错,所以很可能是SecureCRT的本地连接数据出了问题,而换用Terminal连接则可排除这个问题。

#连接SSH
$ ssh -p 22 root@IP


如果出现了登录login输入,则说明确定是SecureCRT问题,这时候只要删除SecureCRT里的连接重新建立一个就可解决。如果没问题login继续往下看。

确认SSH配置

检查/etc/ssh/sshd_config 的 PasswordAuthentication yes,去掉注释,保存,重启ssh服务:service sshd restart

再尝试连接,如果错误消失,解决,否则继续下面。

因为访问权限被拒绝

登陆服务器查看auth.log

cat auth.log
15 11:20:24 hp06 sshd[31533]: Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys


解决办法:chmod 600  /home/user/.ssh/authorized_keys,这里根据你的日志来。

SSH证书不匹配

一般不会是这个原因,但如果以上的方法都无用,你需要把pem证书转为pub证书,并手动指定路径,问题解决。

错误二:Protocol version mismatch

The client has disconnected from the server. Reason: Protocol version mismatch. Required protocol version is 1.3 - 1.99. Received version was 2.0.

提示很明确,是连接协议版本不匹配,解决方法修改成SSH2就行:

QQ截图20200319182716.png

猜你喜欢

转载自blog.51cto.com/sf1314/2480150