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/ssh connections in a file caused known_hosts. Whenever a host name like ‘anchorhost.wpengine.com’ 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.

Easiest fix is to remove the known_hosts file

Since I’m generally only connecting to a few web servers, it’s faster and easier to commonly remove the known_hosts file which is typically located under ~/.ssh/. WP Engine has great removal instructions: https://wpengine.com/support/updating-host-keys-use-sftp/.