This is because SSH corresponds IP addresses and hostnames to the public key submitted by them on first connect; this information is in (on linux, anyway) ~/.ssh/known_hosts
.
If the correspondence is based on a hostname:
[raspberry.pi]:ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNT
And you are using that hostname explicitly to connect, and it belongs to only one remote host you connect to, then you can swap in the new public key as Andyroo suggests -- the easiest way to do that is to just delete the entry in known_hosts
on the system you are trying to ssh from, then connect again and the new key will be stored.
If IP addresses are involved directly at all, though, this becomes messy. Presuming you are on a home LAN and aren't super worried about anyone secretly planting a spoof raspberry pi there, you can instead add this to ~/.ssh/config
, again on the machine you are connecting from:
# Use a CIDR appropriate to your LAN's range if "192.168..." isn't:
Host 192.168.0.*
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
These are documented in man ssh_config
; the first one ditches the check that caused your error, the second prevents the keys from being cached at all.