rust-lang/cargo · error

error: unknown SSH host key The SSH host key for

Error message

error: unknown SSH host key
The SSH host key for `{hostname}` is not known and cannot be validated.

To resolve this issue, add the host key to {known_hosts_location}

The key to add is:

{hostname} {key_type_name} {remote_host_key}

The {key_type_short_name} key fingerprint is: SHA256:{remote_fingerprint}
This fingerprint should be validated with the server administrator that it is correct.
{other_hosts_message}
See https://doc.rust-lang.org/stable/cargo/appendix/git-authentication.html#ssh-known-hosts for more information.

What it means

Error "error: unknown SSH host key The SSH host key for `{hostname}` is not known and cannot be validated. To resolve this issue, add the host key to {known_hosts_location} The key to add is: {hostname} {key_type_name} {remote_host_key} The {key_type_short_name} key fingerprint is: SHA256:{remote_fingerprint} This fingerprint should be validated with the server administrator that it is correct. {other_hosts_message} See https://doc.rust-lang.org/stable/cargo/appendix/git-authentication.html#ssh-known-hosts for more information. " thrown in rust-lang/cargo.

When it happens

Trigger: Thrown at src/sources/git/known_hosts.rs:213 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of rust-lang/cargo@eb98b54bc9 (2026-08-11). Data as JSON: /api/errors/3a6bfe0f52bebb34. Report an issue: GitHub.

Appendix: source

Thrown at src/sources/git/known_hosts.rs:213

            let other_hosts_message = if other_hosts.is_empty() {
                String::new()
            } else {
                let mut msg = String::from(
                    "Note: This host key was found, \
                    but is associated with a different host:\n",
                );
                for known_host in other_hosts {
                    write!(
                        msg,
                        "    {loc}: {patterns}\n",
                        loc = known_host.location,
                        patterns = known_host.patterns
                    )
                    .unwrap();
                }
                msg
            };
            anyhow::bail!(
                "error: unknown SSH host key\n\
                The SSH host key for `{hostname}` is not known and cannot be validated.\n\
                \n\
                To resolve this issue, add the host key to {known_hosts_location}\n\
                \n\
                The key to add is:\n\
                \n\
                {hostname} {key_type_name} {remote_host_key}\n\
                \n\
                The {key_type_short_name} key fingerprint is: SHA256:{remote_fingerprint}\n\
                This fingerprint should be validated with the server administrator that it is correct.\n\
                {other_hosts_message}\n\
                See https://doc.rust-lang.org/stable/cargo/appendix/git-authentication.html#ssh-known-hosts \
                for more information.\n\
                "
            )
        }
        Err(KnownHostError::HostKeyHasChanged {

View on GitHub (pinned to eb98b54bc9)