Useful SSH trick for sysadmins

xsawyerx on 2008-12-29T13:34:45

Do you find yourself connecting on a massive amount of servers? Some according to domain, some according to hostname, some according to /etc/hosts file definitions, some according to IP and so forth?

Do they change either definition with time? Does your SSH client complain about this? (MITM attack usually...)

Do you find yourself spending way too much time on editing and deleting lines from ~/.ssh/known_hosts? Would you like a trick that will make it all much simpler?

function sshdel { perl -i -n -e "print unless (\$. == $1)" ~/.ssh/known_hosts; }
prices may vary, batteries are not included, copyright withheld, patent pending


Thanks to quatro for pasting me this like a year ago :)


SSH hosts

petdance on 2008-12-29T17:40:09

I have nicknames for all my hosts in my ~/.ssh/config.

Re:SSH hosts

xsawyerx on 2008-12-29T17:49:30

That actually sounds like a cool idea, but in most cases the changes of IP numbers are pretty extreme. So I have to both the previous IP association and create the new IP association, so this wouldn't fit me too much.

But if you're using more static addresses to your hosts, that's a pretty cool thing. I'll be reading up on it.
Thanks.

cssh

slanning on 2009-01-05T10:32:25

That reminded me, although it's not for "massive" amounts of ssh connections, there's this tool called `cssh` that I've used the past few months (since my colleague mentioned it). It opens up a terminal window for each server, and you type into a little command-line window and what you type is echoed to all the term windows. It's not perfect, but useful for making quick updates on servers that should be kept in sync.