Okay, let's talk about the SSH client a little bit more.
So what is going on in the SSH client? Well, when first you are logging into an SSH
server, the server host key is cached in the file SSH known hosts and while connecting to a
host the key is checked. And if that key doesn't match, then the connection is refused.
Also, if you want to connect to a non default port, you
can use lowercase p in SSH or uppercase p in SCP.
So SSH Lisa add webhost p2022 for instance.
Let me show you a bit about the server host keys.
So I'm going to do something nasty.
I'm going to edit the ssh now known host file.
There I can see stuff for 138 and I'm
going to mess it up a little bit.
Changing random characters. That should do it.
Another one and the final one. I just want to make sure that whatever happens
I'm getting in trouble if I'm reconnecting. So would that work? Well, let's figure out.
If I'm using SSH to Ubuntu, then what am I getting? Yeah, this
is what I'm getting. This is exactly what I wanted to discuss.
So what do we see? We see warning, remote host identification has changed.
I really like this one. It's possible that someone is doing something nasty
and you might be the victim of a man in the middle attack.
Now I just forced this by changing. The host keys manually.
But normally if this is happening with an Internet based SSH server, then you really might be in
a situation where somebody is doing something nasty or where. You have just recycled an IP address.
So previously you connected to a server. Using the same
name or IP address. That server has been reinstalled.
That might also be what is going on. Now. I can see that
it's complaining about an offending key in the known host's line 4.
Well, let's do a set I4D.
We need a E for edit before that on SSH known host.
If it's really in line 4 then this deletes line 4 and we
can try it again. And as you can see, that worked perfectly.
So now the offending host key has been removed and I can cache the host key again and this time it is
valid. And the next time we have a valid hoax key to connect to. And that's what I wanted to show you.