[clue-tech] ssh, vim helper

Keith Hellman khellman at mcprogramming.com
Sun Oct 19 21:33:23 MDT 2008


On Thu, Oct 16, 2008 at 09:26:59PM -0600, David L. Willson wrote:
> Well, I get them all the time, and I found the easy way to delete the old key, but
> quick.  Notice that it gives you the line-number of the offending key, so you can use
> the "start at line" shortcut when starting vim to go straight to it when you edit your
> known_hosts file.  Like this:
> 
> dlwillson at aurora:~
> $ vim +95 .ssh/known_hosts 
> 
> Now, you just key in ddZZ (dd deletes the bad key, and ZZ saves and quits) and try your
> ssh again.

You can avoid vim altogether with (ironic me saying this, because I
really like vim):
  $ sed -i 95d ~/.ssh/known_hosts

Or put this in your bash environment:
  function unknown_host() { echo sed -i ${1}d ~/.ssh/known_hosts ; }
and you don't need to remember the sed syntax.  I'm sure there a several
other one-liner utilities (perl, ...) that can do the same, just as I'm
sure more such c/l invocations will be added to this thread :^)

It seems they upgrade the cluster machines at Mines a *lot*, so I've
gotten use to doing this immediately afterwards:
  $ ssh-keyscan -t dsa,rsa -f ~/MACHINES >.ssh/known_hosts
This scans all the machine names in the ~/MACHINES file and places their
keys into known_hosts.  This is particularly useful when setting up new
accounts --- as long as you have a useful MACHINES file hanging around.

-- 
Keith Hellman                             #include <disclaimer.h>
khellman at mcprogramming.com                from disclaimer import standard
khellman at mines.edu
                                   -*-                                    
                    public key @ pgp.mit.edu 9FCF40FD 
    Y!M: mcprogramming                           AIM/ICQ: 485403897       
                     gtalk: jabber at mcprogramming.com                      
                                   -*-                                    

"We are born wet, naked, and hungry. Then things get worse."

-- Unknown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://cluedenver.org/pipermail/clue-tech/attachments/20081019/844b5db5/attachment.bin


More information about the clue-tech mailing list