How to Fix “SSH Too Many Authentication Failures” Error

亦凉 2021-05-12 11:37 474阅读 0赞

Sometimes, while trying to connect to remote systems via SSH, you may encounter the error “Received disconnect from x.x.x.x port 22:2: 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.

20190920105306301.png

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:

  1. $ 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.

  1. $ vim ~/.ssh/config
  2. #添加
  3. Host *
  4. IdentitiesOnly=yes

发表评论

表情:
评论列表 (有 0 条评论,474人围观)

还没有评论,来说两句吧...

相关阅读

    相关 How Many Tables

    Problem Description: 今天是伊格内修斯的生日。他邀请了很多朋友。现在是晚餐时间。伊格内修斯想知道他至少需要多少张桌子。你必须注意,并非所有的朋友都彼此认识