GitHub SSH: Fix “REMOTE HOST IDENTIFICATION HAS CHANGED” Safely

Content edited . This editorial update does not represent a new runtime test.

On this page

When Git reports REMOTE HOST IDENTIFICATION HAS CHANGED, stop and compare the presented host key with GitHub’s official fingerprints. Only replace a stale known_hosts entry after confirming the server’s identity. Do not disable host-key checking to make the error disappear.

Why CocoaPods can show a GitHub SSH warning

The original case occurred while CocoaPods cloned a dependency through git@github.com. The failed operation was an SSH identity check underneath dependency installation, not a Podfile syntax error.

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
Host key verification failed.
fatal: Could not read from remote repository.

An unexpected key can reflect a legitimate key rotation, a changed hostname or an intercepted connection. The warning alone cannot distinguish those causes.

Verify the host before editing trust

Compare the exact hostname, key type and fingerprint with GitHub’s published SSH fingerprints. Check GitHub’s official incident or key-rotation notice if relevant. Do not treat ssh-keyscan from the same suspect network as independent identity proof.

If the fingerprint does not match, stop and investigate. GitHub’s host-key verification guidance recommends not connecting when a trustworthy official key cannot be established.

Replace only the confirmed stale entry

For the normal hostname after verification, inspect and remove its old record:

ssh-keygen -F github.com
ssh-keygen -R github.com
ssh -T git@github.com

Back up your known_hosts file first. A custom hostname or port may use a different lookup entry; do not delete the entire file. On reconnect, verify the fingerprint again before accepting the replacement.

Confirm the remaining authentication path

GitHub’s success response says authentication succeeded but shell access is not provided. If identity verification succeeds and access still fails, inspect the remote URL, account key and repository permission separately. Then retry the original Git or CocoaPods operation.

These commands were not executed against a failing connection during this editorial revision. For a different specification-source problem, see CocoaPods CDN errors.

← All articles