Use sed to remove an old known_host

When doing system and network administration on Linux (aka DevOps) its common to make an IP change to the server you are working on and get a known_host man in the middle kind of warning.

ssh [email protected]
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:ghghghhhhhgghhkiugh+g5sVWs16pTYWbH3O82c.
Please contact your system administrator.
Add correct host key in /home/devekko/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/devekko/.ssh/known_hosts:34
remove with:
Host key verification failed.

 

An easy way to remove a bad known_hosts line on say line x

sed -i 'xd' ~/.ssh/known_hosts