Let me show you how that actually works when we use SSH.
Here I'm using SSH to log into udacity.com.
What I see is a message that says the authenticity of the host can't be established.
That means I don't already know a public key for the host.
We can see because I don't already have a public key for udacity.com--
that it cannot establish the authenticity of the host--
it's showing me this finger print, which is a way for it to be more easy for a human to view the key,
rather than seeing all the bites in the key.
If I was very paranoid and careful, what I would do is call up an administrator that I trust
at Udacity and say is this the finger print for our public key.
If I'm less paranoid or more impatient,
then I could connect, and once I connect that public key is going to be stored.
It's added to the list of hosts that I have.
I'm not going to actually continue connecting, but now I have a secure channel
encrypted with some key that's been agreed to using the SSH protocol
to send my password to the Udacity host knowing that it couldn't be intercepted.
But this only has value if I really knew that this was the public key.
Otherwise, I could be talking to anyone.
What's happened as a result of this is now that key has been added to my collection of keys.
Now if I look in the file. ssh/known_hosts, I'll see that I have udacity.com here.
What's been stored is the IP address I was talking to
as well as this is the public key that's stored for udacity.com.
If I try it again, you'll see that it does connect. It has a secure channel now.
It's verified it by checking that the public key that the server sent matched this one.
What's more fun is if I modify this file.
I'm going to make a little change to the public key. Let's change that 4 to a 3.
Now let's try connecting again.
What happens now is we get a very large yelling message with lots of capital letters,
saying that the host identification has changed,
that the host I'm trying to connect to sent back a public key that's different from the one I've stored.
It means that someone could be doing something very nasty.
In this case it means that I just modified the key file,
and they're talking about possibly being eavesdropped on.
It's really not the case that it would be eavesdropping.
It must be an attack in the middle. This is a bit of poor wording in the error message.
It's possible the key changed or something else happened.
So they don't allow you to continue with the connection at this point.
You could modify the file to create a new key, but it's worried enough that something
has gone wrong that it won't let you connect.
