Flux GitRepository SSH "host key verification" error in CI
source-controller cloned over SSH and could not verify the server host key. The known_hosts entry in the referenced secret is missing or does not match the key the git host presented, so the connection is refused.
What this error means
A GitRepository using an ssh:// URL reports "False" with a message about host key verification or a knownhosts mismatch. flux get sources git shows the source stuck.
ssh: handshake failed: knownhosts: key mismatchCommon causes
The secret has no or a stale known_hosts entry
The SSH secret is missing the known_hosts key, or it holds an old host key after the git host rotated its keys, so verification fails.
The identity key is not authorized on the host
The identity private key in the secret is not registered as a deploy key or is missing its matching public key, so SSH cannot authenticate even after the host is trusted.
How to fix it
Regenerate the SSH secret with a fresh known_hosts
- Recreate the git secret so
flux create secret gitscans and pins the current host key. - Add the printed public key as a deploy key on the repository.
- Reconcile the source and confirm it reaches Ready.
flux create secret git infra-ssh \
--url=ssh://git@github.com/acme/infra \
--ssh-key-algorithm=ecdsa
flux reconcile source git infra --with-sourceVerify the known_hosts value matches the host
Compare the stored key with the host key using ssh-keyscan when a mismatch persists after rotation.
ssh-keyscan github.comHow to prevent it
- Pin known_hosts in the secret and refresh it when the host rotates keys.
- Register the generated public key as a read-only deploy key.
- Prefer
flux create secret gitso the host key is scanned correctly.