{"record":{"id":"52a6e6c3e9802163","repo":"rust-lang/cargo","slug":"error-ssh-host-key-has-changed-for-hostname","errorCode":null,"errorMessage":"error: SSH host key has changed for `{hostname}`\n*********************************\n* WARNING: HOST KEY HAS CHANGED *\n*********************************\nThis may be caused by a man-in-the-middle attack, or the server may have changed its host key.\n\nThe {key_type_short_name} fingerprint for the key from the remote host is:\n    SHA256:{remote_fingerprint}\n\nYou are strongly encouraged to contact the server administrator for `{hostname}` to verify that this new key is correct.\n\nIf you can verify that the server has a new key, you can resolve this error by {old_key_resolution}\n\nThe key provided by the remote host is:\n\n{hostname} {key_type_name} {remote_host_key}\n\nSee https://doc.rust-lang.org/stable/cargo/appendix/git-authentication.html#ssh-known-hosts for more information.\n","messagePattern":"error: SSH host key has changed for `\\{hostname\\}`\n\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\n\\* WARNING: HOST KEY HAS CHANGED \\*\n\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\nThis may be caused by a man-in-the-middle attack, or the server may have changed its host key\\.\n\nThe \\{key_type_short_name\\} fingerprint for the key from the remote host is:\n    SHA256:\\{remote_fingerprint\\}\n\nYou are strongly encouraged to contact the server administrator for `\\{hostname\\}` to verify that this new key is correct\\.\n\nIf you can verify that the server has a new key, you can resolve this error by \\{old_key_resolution\\}\n\nThe key provided by the remote host is:\n\n\\{hostname\\} \\{key_type_name\\} \\{remote_host_key\\}\n\nSee https://doc\\.rust-lang\\.org/stable/cargo/appendix/git-authentication\\.html#ssh-known-hosts for more information\\.\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sources/git/known_hosts.rs","lineNumber":264,"sourceCode":"                        located at {old_key_location} line {lineno}, \\\n                        and adding the new key to {known_hosts_location}\",\n                    )\n                }\n                KnownHostLocation::Config { definition } => {\n                    format!(\n                        \"removing the old {key_type_name} key for `{hostname}` \\\n                        loaded from Cargo's config at {definition}, \\\n                        and adding the new key to {known_hosts_location}\"\n                    )\n                }\n                KnownHostLocation::Bundled => {\n                    format!(\n                        \"adding the new key to {known_hosts_location}\\n\\\n                        The current host key is bundled as part of Cargo.\"\n                    )\n                }\n            };\n            anyhow::bail!(\n                \"error: SSH host key has changed for `{hostname}`\\n\\\n                *********************************\\n\\\n                * WARNING: HOST KEY HAS CHANGED *\\n\\\n                *********************************\\n\\\n                This may be caused by a man-in-the-middle attack, or the \\\n                server may have changed its host key.\\n\\\n                \\n\\\n                The {key_type_short_name} fingerprint for the key from the remote host is:\\n\\\n                    SHA256:{remote_fingerprint}\\n\\\n                \\n\\\n                You are strongly encouraged to contact the server \\\n                administrator for `{hostname}` to verify that this new key is \\\n                correct.\\n\\\n                \\n\\\n                If you can verify that the server has a new key, you can \\\n                resolve this error by {old_key_resolution}\\n\\\n                \\n\\\n                The key provided by the remote host is:\\n\\","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/sources/git/known_hosts.rs#L246-L282","documentation":"Error \"error: SSH host key has changed for `{hostname}`\n*********************************\n* WARNING: HOST KEY HAS CHANGED *\n*********************************\nThis may be caused by a man-in-the-middle attack, or the server may have changed its host key.\n\nThe {key_type_short_name} fingerprint for the key from the remote host is:\n    SHA256:{remote_fingerprint}\n\nYou are strongly encouraged to contact the server administrator for `{hostname}` to verify that this new key is correct.\n\nIf you can verify that the server has a new key, you can resolve this error by {old_key_resolution}\n\nThe key provided by the remote host is:\n\n{hostname} {key_type_name} {remote_host_key}\n\nSee https://doc.rust-lang.org/stable/cargo/appendix/git-authentication.html#ssh-known-hosts for more information.\n\" thrown in rust-lang/cargo.","triggerScenarios":"Thrown at src/sources/git/known_hosts.rs:264 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}