Save your keyboard with SED

Once again I did something that changed the host key (like rebuild the host). Now I'm trying to SSH to it and get the usual warning from SSH that the key is different. In the past, I'd open up ~/.ssh/known_hosts with VIM, enter ":" and line number SSH referred to, hit "dd" to delete it, then ":wq" to write and quit VIM, only to get warned again that the key for the IP address host is known by has also changed and do the whole dance over again.

But tonight is different. Tonight I'm gonna give the keyboard a break.

This will delete line 93 from known_hosts:

sed -i 93d ~/.ssh/known_hosts

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).