FG
šŸ’» Software

How do I clear out the ssh-agent entries (on Mac OS X )?

Fresh7 days ago
Mar 15, 2026173429 views
Confidence Score1%
1%

Problem

I'm running Mac OS X, and it appears that after SSHing to several machines, using identity files, my 'ssh-agent' builds up a lot of identity / keys and then sometimes offers too many to a remote machine, causing them to kick me off before connecting: Received disconnect from 10.12.10.16: 2: Too many authentication failures for cwd It's pretty obvious what's happening, and this page talks about it in more detail: SSH servers only allow you to attempt to authenticate a certain number of times. Each failed password attempt, each failed pubkey/identity that is offered, etc, take up one of these attempts. If you have a lot of SSH keys in your agent, you may find that an SSH server may kick you out before allowing you to attempt password authentication at all. If this is the case, there are a few different workarounds. Rebooting clears the agent and then everything works OK again. I can also add this line to my file to force it to use password authentication: Anyhow, I saw the note on the p…

Error Output

PreferredAuthentications keyboard-interactive,password

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I clear out the ssh-agent entries (on Mac OS X )?

Low Risk

Your SSH keys should not get automatically added to the agent just because you SSH'ed to a server... Run to list the agent's keys, to clean out all keys.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment