How to remove old SSH key from server trusted keys

Hey I am changing my SSH key.

How do I remove my old SSH key from my servers trusted keys.
burnedfacelessAsked:
Who is Participating?
 
arnoldConnect With a Mentor Commented:
You edit it out from ~/.ssh/authorized_keys*

Usually, the key resides in the above file on the user account to which you connect.
0
 
Pallavi GodseSr. Digital Marketing ExecutiveCommented:
If you want to remove all hosts with known keys -
just remove file ~/.ssh/known_hosts

If you do not want to delete all the hosts in ~/.ssh/known_hosts, then simply:

ssh-keygen -R hostname

Open in new window


Where hostname is the one you wish to remove.

You will get the following warning -

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
f2:92:1d:da:81:2a:d7:16:0a:48:f0:43:20:1c:f4:b5.
Please contact your system administrator.
Add correct host key in /home/novak/.ssh/known_hosts to get rid of this message.
Offending key in /home/novak/.ssh/known_hosts:1

If you see this, confirm the server host key has changed before you simply delete the key from known_hosts, otherwise you may not be connecting to the server you think you are
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.