Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

xsawyerx (8978)

xsawyerx
  (email not shown publicly)

Journal of xsawyerx (8978)

Monday December 29, 2008
08:34 AM

Useful SSH trick for sysadmins

[ #38176 ]
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 :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I have nicknames for all my hosts in my ~/.ssh/config.
    --

    --
    xoa

    • 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.
  • 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.