Received disconnect from 192.168.0.123: 2: Too many authentication failures
Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Received disconnect from 192.168.0.123: 2: Too many authentication failures
I am running CentOS 7.3 + X Windows system + Mate-desktop on all of my systems except for a couple of old 32 bit boxes which have Ubuntu 16.04 Mate. On my main workstation I created ssh keys to various other machines using Seahorse. The first 5 were created with no problem. On the 6th attempt I received an error such as the example in the subject when I attempted to setup the key on the remote machine.
I determined that if I uncommented the #MaxAuthTries line in /etc/ssh/sshd_conf file on the remote machine, bumped up the number to 6 and restarted sshd, I could create the key. On the next machine I had to bump it to 7 etc. I reported this as a bug in Seahorse - still waiting for a response from the project.
I also noticed that if I attempt to connect with ssh to the 6th machine - the one with "MaxAuthTries 6" - after creating the 7th key I again get the "too many" error. It seems that the ssh command in a terminal is trying all of the available keys to access the remote computer instead of the correct key for that server.
I have set MaxAuthTries to 10 on all of my machines which eliminates the symptom. However, I do not think it resolves the underlying issue.
Is there something I need to configure on the workstation which is initiating the connections?
I also noticed that if I attempt to connect with ssh to the 6th machine - the one with "MaxAuthTries 6" - after creating the 7th key I again get the "too many" error. It seems that the ssh command in a terminal is trying all of the available keys to access the remote computer instead of the correct key for that server.
It's a problem with how the agents work currently. There is no way they have to work out which key should be offered to which server, so they just start trying keys. What might work is to add entries in ~/.ssh/config for each remote host and set IdentitiesOnly to "yes" and point IdentityFile to the right private key.
Turbocapitalist, I just posted a moderator-note ... praising this reply ... to the effect that "bits of wisdom like the foregoing ought to be put into a sticky topic at the top of this forum."
I suggested a thread title: "Security Tips, Tricks, and Folk Wisdom."
Everyone who has "more than so-many SSH servers and therefore keys to deal with" has bumped into this issue. But, I find very little discussion of it.
LQ needs a sticky thread ... "If you want to minimize security-related ... and of course you do ... readthisthread!"
Last edited by sundialsvcs; 03-15-2017 at 11:46 AM.
It's useful but far from perfect because as far as I know you have to keep entering the key information.
Currently to still keep the key in the agent, you have to fiddle the MaxAuthTries on the SSH server similar to how taylorkh has started. However, the increased MaxAuthTries can be restricted using a Match block to a single group of users, an individual user, a network,
Code:
Match Group fungames
MaxAuthTries 20
or some of each.
Code:
Match Group fungames, Address 192.168.1.0/24
MaxAuthTries 20
It will still clutter the authentication logs with all the failures though.
I just had a chance to check with older (6.6p) and newer (7.4) OpenSSH clients. With the latter, it is seems enough to specify IdentityFile only. Sometime between the two, the client got a lot more adaptable.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.