Resolving SFTP Errors After Server Migrations

Have you ever connected to a web server over SFTP? If so then it’s likely you’ll see one of these errors at some point: remote host identification has changed , host keys changed, offending key for IP or something similar.

This is somewhat common due to how SFTP operates

Your computer tracks SFTP and SSH connections in a file caused known_hosts. Whenever a server name like points to a new IP, it sees the different IP and refuses to connect until you tell your computer to accept the new IP address. This can be done by remove the line with the host name from the known_hosts file or by deleting the file altogether like this.

rm ~/.ssh/known_hosts

Easiest fix is to remove the known_hosts file

I’m generally only connecting to a few web servers so it’s faster and easier to remove the known_hosts file located under ~/.ssh/. If you prefer to correct an individual web server then following Kinsta’s instructions: