# Git "Host key verification failed" in CI

> Fix the Git "Host key verification failed" error in CI over SSH, caused by github.com not being present in the runner known_hosts file.

Source: https://latchkey.dev/learn/git/git-host-key-verification-failed-in-ci  
Updated: 2026-06-26

SSH would not connect because it could not verify the server host key against known_hosts. On a fresh CI runner the host is simply unknown, and non-interactive SSH refuses to trust it on the fly.

## 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 "Host key verification failed" in CI?

There are 2 common causes: github.com missing from known_hosts and outdated or rotated host key. A clean runner has no known_hosts entry, and strict checking rejects the unverified host.

### How do I fix Git "Host key verification failed" in CI?

There are 2 fixes depending on which cause you have: add the host key before connecting and pin the verified key (preferred). Work through them in order, since the first is the most common.

### What does Git "Host key verification failed" in CI actually mean?

An SSH clone or push fails with Host key verification failed and fatal: Could not read from remote repository.

### How do I stop Git "Host key verification failed" in CI happening again?

Seed known_hosts with the published GitHub fingerprints as part of runner setup so SSH steps never hit an unknown host.

---

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
