sshdel delete ssh key by line number

I find this really useful, just a call out to sed so I don't have to remember the syntax.


ssh_delete_key() {
sed -i -e ${1}d ~/.ssh/known_hosts
}
alias sshdel=ssh_delete_key

Usage:

[thomas@laptop: ~] $ ssh 192.168.0.1
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 RSA key sent by the remote host is
b7:da:35:ad:65:1c:5b:09:cf:a5:b3:e6:e7:0e:cf:43.
Please contact your system administrator.
Add correct host key in /home/thomas/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/thomas/.ssh/known_hosts:426
RSA host key for 192.168.0.1 has changed and you have requested strict checking.
Host key verification failed.
[thomas@laptop: ~] $ sshdel 426
[thomas@laptop: ~] $ ssh 192.168.0.1
The authenticity of host '167.143.72.26 (167.143.72.26)' can't be established.
RSA key fingerprint is b7:da:35:ad:65:1c:5b:09:cf:a5:b3:e6:e7:0e:cf:43.
Are you sure you want to continue connecting (yes/no)?

About the Author...

Slides from LISA 2019 Linux systems troubleshooting #LISA2019 https://t.co/D4dMKflK6R Tue Oct 29 05:59:30 +0000 2019

https://t.co/AGeihMALAv configuring grub2 with EFI Fri Sep 13 05:20:01 +0000 2019

I published a Thing on @thingiverse! https://t.co/IYpRyEb7Hz #thingalert Tue Jul 23 19:27:57 +0000 2019

Nokogiri install on MacOSX https://t.co/v3An0miW9L Fri Jul 12 15:06:49 +0000 2019

HTML email with plain mailer plugin on Jenkins https://t.co/Z6FSDMDjy8 Thu Jul 11 21:07:25 +0000 2019