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 ]

Matts (1087)

Matts
  (email not shown publicly)

I work for MessageLabs [messagelabs.com] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Friday January 23, 2004
10:49 AM

New app I want to write...

[ #16973 ]

I call this "mssh" (Matt's ssh).

It should remember that if I type:

mssh 10.2.1.1

I really mean

ssh msergeant@10.2.1.1

. But if I try

mssh 10.2.2.2

it should remember I wanted

ssh msergeant@10.2.2.2

.

See I use different usernames in different places. It should be smart enough to cache the user I use on different hosts. And perhaps ask if it hasn't cached one before.

Should be quite trivial to write.

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.
  • Shell script? (Score:3, Insightful)

    by 2shortplanks (968) on 2004.01.23 11:14 (#27643) Homepage Journal
    Sounds like you don't want an application but a nice shell alias that passes your arguments though a perl script and reprocesses them before the shell script passes them to ssh.

    That way you won't have to worry about the nightmare of dealing with forking, IO transfer, terminals, and ...the list goes on

  • With openssh you can setup ~/.ssh/config to do this for you. For instance, at work I'm 'wintercm' while almost everywhere else I'm 'cwinters'. So in ~/.ssh/config I have:

    Host mail.optiron.com
    User wintercm

    And then I can just do 'ssh mail.optiron.com' and it adds the '-l wintercm' in there for me. You can have as many of these 'Host' declarations as you want.

    • Re:ssh config? (Score:5, Informative)

      by da (1525) on 2004.01.23 11:46 (#27647) Homepage Journal
      This also works with arbitrary hostnames, so if you hate typing 'ssh 10.253.189.42' you can shorten it to 'ssh work' in .ssh/config via:

      Host work
      User blah
      HostName 10.253.189.42

      ...
      This also works with ports, X11Forwards, etc.

      There's more info in 'man ssh_config' and <plug>I wrote an article [linuxjournal.com] for LJ on it too.</plug>

      --

      -DA [coder.com]

      • Perfect! BTW Matt you used the same username twice AFAICS ;)
      • That's a really useful article -- thanks for the pointer!
      • The trouble with shortening hostnames is that you still have to type the whole hostname. It's much easier if you can just complete the whole hostname as a command. So, here's a little snippet from my .zshrc (although there's nothing specific to zsh in it, and it should work fine in bash).

        if [ -f ~/.ssh/known_hosts ] ; then
            while read host junk
            do
                host=${host%%,*}
                alias "${host}=ssh ${host}"
            done < ~/.ssh/known