[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Sed or awk: remove a line from a file



As I regularly format my test box, I often get stuck SSHing into it, like this:

$ ssh user@domain
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:44
RSA host key for domain has changed and you have requested strict checking.
Host key verification failed.



Now, I need strict checking but I'd like to just remove line 44 from
~/.ssh/known_hosts. Easy to do in VIM, probably even easier to do in
sed or awk. But I've been reading sed and awk tutorials for two hours
and I cannot figure out how to remove line N from the file without
creating a second file. If I'm already going through the hassle of
creating then moving a second file then I might as well just edit the
file in VIM.

Any ideas?

Thanks.

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com


Reply to: