SSH (Secure Shell) is a popular way for developers and administrators to connect to remote systems in a secure manner and transfer data. But sometimes, while trying to connect to your server you may get the error saying ‘Too Many Authentication Failures’ and might be disconnected or not be able to establish a connection at all. In this article, we will learn how to fix ‘too many authentication failures’ SSH error in Linux.
This issue mainly occurs if there are too many SSH connection attempts made from your machine to remote server. For example, if you have many SSH keys stored on your system, then the SSH client will try to connect to your remote server using each of your keys stored on your system. Since SSH server on remote system requires a specific key for connection it rejects connection attempts made using other keys and eventually shows you ‘too many authentication failures’ message.
Fix “Too Many Authentication Failures” SSH Error
Here are the steps to fix this problem. There are a couple of ways to solve this problem. You can either set IdentitiesOnly option in command line from the client side, or set it permanently in your remote server’s configuration file.
1. Using IdentitiesOnly
First of all, we will set IdentitiesOnly flag to yes. This will instruct SSH to use only authentication files that are either specified in command line or mentioned in SSH configuration file. Here is an example command.
$ ssh -o IdentitiesOnly=yes test_user
This approach needs to be implemented from SSH client side and not server side.
2. Updating SSH config file
In above approach, you will need to set IdentitiesOnly option every time you run SSH command. If you don’t want to set IdentitiesOnly option every time you run SSH command, you can alternatively update SSH config file to set it permanently.
Open terminal on your SSH server (not client) and run the following command to open SSH config file.
$ vim ~/.ssh/config
Add the following line under Host * section.
Host * IdentitiesOnly=yes
Now you should be able to connect to SSH without specifying IdentitiesOnly option.
If you are still getting the error even after making the above change, just restart your SSH service to apply changes.
$ sudo systemctl restart sshd # RHEL/CentOS/Fedora OR $ sudo systemctl restart ssh # Ubuntu/Debian
This approach needs to be implemented from SSH server side and not client side.
In this article, we have learnt how to fix ‘too many authentication failures’ SSH error in Linux. SSH is the de facto way to connect to remote servers in Linux and in most other systems. If you are only connecting via SSH once in a while, or if you don’t have access to the configuration file on your remote server, then you can set IdentitiesOnly option directly in your command, as per approach #1 above. If you are regularly connecting to your remote server via SSH, or if you have access to your remote server’s configuration file, then it is advisable to update the configuration file as described in 2nd approach above.
Also read:
How to List All Virtual Hosts in Apache
How to Create Virtual Hard Disk Volume from File in Linux
How to Downgrade Software in Ubuntu
How to Downgrade RHEL/CentOS to Previous Minor Release
How to Mount Windows Partition in Ubuntu
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.