How to solve “Too many authentication failures for…” problem

Recently I am having trouble connecting to my home server from my laptop. Every time I connect, it said:

Received disconnect from my_ip: 2: Too many authentication failures for my_username

The strange thing is, connect from any other machine did not give me this problem. Is there anything wrong with my laptop? Even with multiple failures, my home server should reset login count sometimes.

Turn out the problem belongs to my SSH keys. I recently added 2 keys to my newly deployed servers. Each time I connect to my home server, my laptop will offer public key one by one, and apparently I have more private keys than the maximum number of retries, which is 6 on my home server.


  1. Explicitly specify the correct private key in host entry in the ~/.ssh/config file by adding IdentitiesOnly:

    Host my_home_server_ip IdentityFile ~/.ssh/some_rsa_key IdentitiesOnly yes Port 22

  2. Specify the correct private key:

    ssh -i some_id_rsa -o ‘IdentitiesOnly yes’ username@my_home_server_ip

  3. The last resort, disable Public Key Authentication completely:

    ssh -o PubkeyAuthentication=no username@my_home_server_ip

Happy connecting!