Is there an easy way to update information in known_hosts when you know that a hosts key has changed?

Use ssh-keygen -R hostname to remove the hostname (or IP address) from your known_hosts file. The next time you connect, the new host key will be added to your known_hosts file.


TARGET_HOST=[hostname or IP]

# Remove the old key(s) from known_hosts
ssh-keygen -R $TARGET_HOST

# Add the new key(s) to known_hosts (and also hash the hostname/address)
ssh-keyscan -H $TARGET_HOST >> ~/.ssh/known_hosts

The next time you connect, you'll connect without being asked Are you sure you want to continue connecting (yes/no)? since the keys will already be in the known_hosts file.