Remove offending key from known_hosts file with one swift move

sed -i 18d .ssh/known_hosts

January 16, 2013EvaggelosBalaskas

Explanation

Using sed to remove a specific line.

The -i parameter is to edit the file in-place.

Limitations

This works as posted in GNU sed. In BSD sed, the -i flag requires a parameter to use as the suffix of a backup file. You can set it to empty to not use a backup file:

sed -i'' 18d .ssh/known_hosts

Related one-liners

Remove offending key from known_hosts file with one swift move

vi +18d +wq ~/.ssh/known_hosts

October 30, 2012bashoneliners

Alternative one-liners