Fix "Too many authentication failures" SSH error
This topic describes the causes and solutions for the "Too many authentication failures" error when connecting to a Linux instance from a third-party SSH client.
Symptoms
When you use a third-party SSH client to connect to a Linux instance, the connection fails with the error message "Too many authentication failures".
Remote side sent disconnect message
type 2 (protocol error):
"Too many authentication failures"
Cause
The SSH service's configuration file, /etc/ssh/sshd_config, on the ECS instance contains a password retry limit. This error occurs if you exceed the allowed number of password attempts.
This setting does not lock the user account; it only disconnects the current session. You can try to log on again immediately.
Resolution
If you still cannot log on after multiple password attempts, reset the password and try again. For more information, see Reset the logon password of an instance.
The password retry limit enhances the security of your ECS instance. Before you modify this setting, carefully weigh the security benefits against your ease-of-use requirements. If you decide to change the retry limit, follow these steps.
-
Log on to the ECS instance using VNC.
For more information, see Log on to a Linux instance using password authentication.
-
Run the following command to check the sshd_config file for a configuration similar to the one shown below:
cat /etc/ssh/sshd_configA response similar to the following indicates that the system terminates the SSH connection after six consecutive failed password attempts.
MaxAuthTries 6NoteThe
MaxAuthTriesparameter, which is disabled by default, specifies the maximum number of authentication attempts allowed per SSH connection. If this limit is exceeded, the system drops the SSH connection and returns an error. -
Modify the SSH configuration.
-
Open the SSH configuration file.
vi /etc/ssh/sshd_config -
Modify the password retry limit as needed.
To disable the retry limit, comment out the line by prefixing it with a number sign (
#), as shown below.# MaxAuthTries 6 -
Press the Esc key and enter
:wqto save the file and exit.
-
-
Run the following command to restart the SSH service:
systemctl restart sshd.service