问题描述:ssh err: Server responded "Too many authentication failures for "users"" ...
前一段时间使用SSH Secure Shell Client 工具,采用public key认证方式登录一切正常;
新增一对密钥,再次采用public key认证方式登录,出现以下错误(但可以使用密码认证方式正常登录):
意思是使用root用户认证失败次数过多,无法登录。
问题分析:
1、检查配置文件/etc/ssh/sshd_config,无错误配置;
2、检查密钥都正常导入;
3、重新安装ssh服务与SSH Secure Shell Client ,问题依旧;
4、使用debugging
使用SSH Secure Shell Client -->Help -->Debugging...
勾选Enable Debugging ,Debug级别3,Debug日志文件debug_log.txt;
再次登录,无法登录,查看Debug日志(部分内容):
server offers auth methods 'publickey,gssapi-with-mic,password'.
Ssh2AuthPubKeyClient/authc-pubkey.c:1794: Starting pubkey auth...
Ssh2AuthPubKeyClient/authc-pubkey.c:1751: Agent is not running.
Ssh2AuthPubKeyClient/authc-pubkey.c:1549: Got 0 keys from the agent.
Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "C:\Documents and Settings\Administrator\Application Data\SSH\UserKeys\te1auth_key" to candidates
Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "C:\Documents and Settings\Administrator\Application Data\SSH\UserKeys\te2auth_key" to candidates
Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "C:\Documents and Settings\Administrator\Application Data\SSH\UserKeys\te3auth_key" to candidates
Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "C:\Documents and Settings\Administrator\Application Data\SSH\UserKeys\te4auth_key" to candidates
Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "C:\Documents and Settings\Administrator\Application Data\SSH\UserKeys\te5auth_key" to candidates
Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "C:\Documents and Settings\Administrator\Application Data\SSH\UserKeys\te7auth_key" to candidates
Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "C:\Documents and Settings\Administrator\Application Data\SSH\UserKeys\te8auth_key" to candidates
Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "C:\Documents and Settings\Administrator\Application Data\SSH\UserKeys\vm8key" to candidates
Ssh2AuthPubKeyClient/authc-pubkey.c:1529: Trying 8 key candidates.
SshTcp/sshwintcp.c:187: winsock writing 1104
通过Debug日志分析,SSH Secure Shell Client使用public key方式远程登录的过程, 在认证过程中查找认证文件是逐个依次查找的,所以查找了前面的七个,都不是与之相对应的认证文件,所以都没成功登录,这样才会出现登录失败次数过多的提示。找到了登录失败的原因之后,问题就好解决了,先删除其他的认证文件,再登录,又可以正常登录了。
总结:出现问题之后,先分析出现问题之前与出现问题之后有什么改变,把改变的部分与出错信息联想起来分析,习惯查看日志信息,有助于快速解决问题。
附:这个问题困扰了我很多天,在百度、Google没有搜索到有用的信息,有类似的问题,却没有实质性的解决问题。今天通过自己的分析把问题解决了,稍微有点儿欣慰,记下来,希望能帮助遇到此类问题的朋友。