How to Fix “SSH Too Many Authentication Failures” Error
Sometimes, while trying to connect to remote systems via SSH, you may encounter the error “Received disconnect from x.x.x.x port 22 Too many authentication failures”. In this short article, I will explain how to fix this error in a few simple steps.
Read Also: 4 Ways to Speed Up SSH Connections in Linux
Following is a screenshot of the error I encountered, while using the ssh client.
I discovered that this resulted from existence of many ssh identity keys on my machine, and each time I run the ssh client, it would try all my ssh keys known by the ssh-agent and all other keys, when attempting to connect to the remote server (vps2 as shown in the above screenshot). This is the default behavior of ssh.
Since ssh server (sshd) on the remote server expects a particular identity key, the server rejects the connection and ssh client aborts with the above error.
To fix this error, you need to add the IdentitiesOnly
with a value of yes
, which instructs ssh to only use the authentication identity files specified on the command line or the configured in the ssh_config file(s), even if ssh-agent offers additional identities.
For example:
$ ssh -o IdentitiesOnly=yes vps2
Alternatively, if you want this to work for all ssh client connections, you can configure it in your ~/.ssh/config
file.
$ vim ~/.ssh/config
#添加
Host *
IdentitiesOnly=yes
还没有评论,来说两句吧...