Rebuilt server and can't SSH in now
I had to rebuild my server. When I tried to login with my old SSH keys, I get an error saying "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" and it will not allow me to login.
I logged into my account and accessed the Lish console. Following the documentation here, I reset my root password and started the SSH server. But, when I log into my server, I still get the same error and can't access my server. What am I supposed to do here?
This is actually a form of protection used by the SSH protocol.
When you first connect to a server you've never connected to before, your SSH client will ask if you want to remember the host key. When you next connect to the server, it will check the key the server provided against the key that was cached when you connected the first time.
In your case, because you've rebuilt your Linode, it now has a new host key, so your client is warning you the key has changed.
You need to tell your SSH client to remove the key it cached previously, so the next time you connect, it will see it as a new server and prompt you to save the key again.
How you do that, very much depends on your SSH client and OS. Here's an article to get you started - if you let us know what you're using to connect to your Linode, we can guide you a bit more.
It's a good idea to clean out
known_hosts periodically. There's no risk in having extraneous stuff in it but, if you use a lot of systems (as the case may be at work), it's worth the little effort it takes to stay on top of it. If you delete an entry you shouldn't have, you'll just be asked to accept the remote system's public key again.
Here's how to manage your
known_hosts on Linux/BSD:
Thanks for the responses. I was able to go in and clear out the old SSH keys. I'm able to SSH as root, but I'm seeing some weird behavior. Instead of seeing root@myipaddress as the logged in user, it's root@0. Additionally, per the tutorial I'm following, I'm trying to set up a hostname via the hostnamectl command, but I get an error saying "command not found." Is this expected behavior?
root@1 probably refers to
root@localhost. ::1 is the IPv6 address of localhost (the IPv6 equivalent of 127.0.0.1).
I have hostnamectl(1) on my Debian 10 system:
stevewi@dave:~$ whereis hostnamectl
hostnamectl: /usr/bin/hostnamectl /usr/share/man/man1/hostnamectl.1.gz
Does your PATH include /usr/bin? Alternatively, you can just edit /etc/hostname to do this (FWIW, since I'm a very old fart, this is how I've done it since possibly the beginning of time ;-) ). What you need to do is outlined here: