# Git SSH "Too many authentication failures" in CI

> Fix Git SSH "Received disconnect ... Too many authentication failures" in CI - the agent offers too many keys before the right one, exhausting the server limit.

Source: https://latchkey.dev/learn/git/git-too-many-authentication-failures  
Updated: 2026-06-25

SSH offered the server more keys than it allows before reaching the correct one. With several identities loaded in the agent, the server hits its max-auth-tries limit and disconnects before the right key is tried.

## Diagnose it: depth, refs, or credentials?

```Terminal
git rev-parse --is-shallow-repository
git rev-parse --abbrev-ref HEAD    # prints HEAD when detached
git log --oneline -3
git remote -v
```

> `actions/checkout` fetches depth 1 on a detached HEAD. Anything diffing against a base, reading a branch name, or running `git describe` needs `fetch-depth: 0`.

## FAQ

### What causes Git SSH "Too many authentication failures" in CI?

There are 2 common causes: the agent offers too many keys and the right key is not prioritized. SSH tries each identity in the agent in turn.

### How do I fix Git SSH "Too many authentication failures" in CI?

There are 2 fixes depending on which cause you have: force only the intended key and limit the agent to the deploy key. Work through them in order, since the first is the most common.

### What does Git SSH "Too many authentication failures" in CI actually mean?

An SSH clone fails with Received disconnect from ...: Too many authentication failures.

### How do I stop Git SSH "Too many authentication failures" in CI happening again?

Load only the key a job needs into the agent. The prevention section lists 3 changes that keep it from recurring.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
