How to recover from "Too many Authentication Failures for user root"
"Too many Authentication Failures for user root" means that Your SSH server's MaxAuthTries limit was exceeded. It happens so that Your client is trying to authenticate with all possible keys stored in /home/USER/.ssh/ .
This situation can be solved by these ways:
- ssh -i /path/to/id_rsa root@host
- Specify Host/IdentityFile pair in /home/USER/.ssh/config .
- Increase MaxAuthTries value on the SSH server in /etc/ssh/sshd_config (not recommended).
If you get the following SSH Error:
$ Received disconnect from host: 2: Too many authentication failures for root
This could happen if you have (default on my system) five or more DSA/RSA identity files stored in your
.ssh directory. In this case if the
-i option isn't specified at the command line the ssh client will first attempt to login using each identity (private key) and next prompt for password authentication. However, sshd drops the connection after five bad login attempts (again default may vary).
So if you have a number of private keys in your .ssh directory you could disable
Public Key Authentication at the command line using the
-o optional argument.
$ ssh -o PubkeyAuthentication=no root@host
On the remote machine open /etc/sshd_config and change value
This is typical problem when You have installed multiple keys or open multiple connections. Server checking step by step each key and if MaxAuthTries is setup on 3 then after first 3`rd tries will disconnect You. Typical ssh security.
I suggest You to use verbose mode during connection to remote machine to analyze problem.
ssh -v -p port_number user@servername
Guessing like most poeple on this forum do is WRONG and its wasting of time. First try to analyze problem, collect informations and then ask.
For me this problem was solved by creating the below ssh_config for the host I was connecting to.
The problem occurred because I have way too many ssh keys in my
~/.ssh folder, like 16 or so. And without both of those
IdentitiesOnly directives in the config, my machine was apparently trying all of the keys in
~/.ssh and reaching the max number of attempts before attempting the correct IdentityFile.
This is bad practice. Just have a regular user on the remote box and connect through ssh using it, then gain root access using su/sudo.