Perl (Scripting) - Resolve "Host key for has changed"

by
Jeremy Canfield |
Updated: November 11 2020
| Perl (Scripting) articles
This error appears when attempting to make an SSH connection using a Perl SSH module, such as Net::SSH:Perl.
Host key for 'server1' has changed
Let's say you are invoking the Perl script as john.doe. In this scenario, on a Linux system, the public certificate in John Doe's known_hosts file (/home/john.doe/.ssh/known_hosts) does not match the public certificate being issued by the target server.
You can simply remove the public certificate from John Doe's known_hosts file, and the error should no longer occur.
Did you find this article helpful?
If so, consider buying me a coffee over at