Tuesday, August 23, 2011

vim tip: open a file at a given line

Today, I've got this error from an ssh command:

$ ssh qbert
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
c5:f1:e3:66:81:2f:6e:e1:6a:41:1b:21:a2:05:45:f3.
Please contact your system administrator.
Add correct host key in /home/giallu/.ssh/known_hosts to get rid of this message.
Offending key in /home/giallu/.ssh/known_hosts:84
RSA host key for qbert has changed and you have requested strict checking.
Host key verification failed.
lost connection

The key changed because I reinstalled that machine so there is not really anyone trying nasty things, I just need to get rid of that line (84). In order to open the file in vim at that line I used:

$ vim +84 /home/giallu/.ssh/known_hosts

followed by "dd" (delete line) and ":wq" (save and exit)

That's all for today's vim trick...