Skip to content
Latchkey

Git "Host key verification failed" in CI

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.

What this error means

An SSH clone or push fails with Host key verification failed and fatal: Could not read from remote repository. There is no prompt because CI runs non-interactively.

git
No ECDSA host key is known for github.com and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

Common causes

github.com missing from known_hosts

A clean runner has no known_hosts entry, and strict checking rejects the unverified host.

Outdated or rotated host key

A pinned known_hosts entry no longer matches after GitHub rotated its keys.

How to fix it

Add the host key before connecting

  1. Pre-populate known_hosts with the current GitHub key.
  2. Or, for the first connect only, accept new keys automatically.
Terminal
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts

Pin the verified key (preferred)

  1. Use the published GitHub SSH key fingerprints rather than blindly trusting whatever responds.
  2. Refresh the pinned entry if GitHub rotates keys.
Terminal
ssh -o StrictHostKeyChecking=accept-new -T git@github.com

How to prevent it

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

Frequently asked questions

What causes ""Host key verification failed""?
A clean runner has no known_hosts entry, and strict checking rejects the unverified host.
How do I fix "Host key verification failed"?
Add the host key before connecting

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card