One Liner Remove Offending Key sed

Written by
Date: 2011-09-18 15:16:00 00:00


This is a small tip if you want to remove a line from a file, this is particularly useful when you get this message:

Warning: the ECDSA host key for 'garron.me' differs from the key for the IP address '200.87.133.237'
Offending key for IP in /home/gentoo/.ssh/known_hosts:20
Matching host key in /home/gentoo/.ssh/known_hosts:48
Are you sure you want to continue connecting (yes/no)?

So in this case I may use this command:

sed -i 20d ~/.ssh/known_hosts

You can use it in other situations as well.