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.
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
- Pre-populate known_hosts with the current GitHub key.
- Or, for the first connect only, accept new keys automatically.
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hostsPin the verified key (preferred)
- Use the published GitHub SSH key fingerprints rather than blindly trusting whatever responds.
- Refresh the pinned entry if GitHub rotates keys.
ssh -o StrictHostKeyChecking=accept-new -T git@github.comHow to prevent it
- Seed known_hosts with the published GitHub fingerprints as part of runner setup so SSH steps never hit an unknown host.