How to Keep ssh-agent from Sticking its Nose Where it Doesn't Belong
For the longest time, I've been fighting with this problem:
$ ssh someserver.ca Received disconnect from 188.8.131.52: 2: Too many authentication failures for username
It never asked for my password, it just flat-out failed. After some digging, I realised that the force behind this was my use of ssh-agent, a daemon that holds onto the myriad of keys (and their respective passwords) that I use to access all of my servers. It turns out that by default ssh-agent attempts to use every key you've got to access a server. However, because the destination server usually rejects login attempts > 6, the whole thing blows up before it ever gets to the "enter your password" step.
The solution is this handy one-liner in your ssh client config (~/.ssh/config or /etc/ssh/ssh_config):
Host * IdentitiesOnly yes
Contrary to what you might think this means, IdentitiesOnly doesn't force the use of identities, rather it tells the client to only use identities explicitly defined for this host. This way my client uses identities assigned to a host via the config, and if one isn't set, it isn't used.
Why this isn't the default is beyond me.