Re: openssh configuration question: domain -> username mapping

From: Richard E. Silverman (slade@shore.net)
Date: 05/28/02


From: slade@shore.net (Richard E. Silverman)
Date: 28 May 2002 14:47:42 -0400


>>>>> "NZ" == Neil Zanella <nzanella@cs.mun.ca> writes:

    NZ> I am running openssh 3.1p1 as revealed by rpm -qa 'openssh*'. I
    NZ> would like to configure my ~/.ssh/config so that when I connect to
    NZ> doamin foo.net I am logged in as userfoo and when I connect to
    NZ> domain bar.net I am logged in as userbar, automatically so that I
    NZ> don't have to type the userfoo@ part of the SSH URL on the command
    NZ> line. Is this possible?

% man ssh
...
CONFIGURATION FILES
     ssh obtains configuration data from the following sources in the follow­
     ing order: command line options, user's configuration file
     ($HOME/.ssh/config), and system-wide configuration file
     (/etc/ssh_config). For each parameter, the first obtained value will be
     used. The configuration files contain sections bracketed by ``Host''
     specifications, and that section is only applied for hosts that match one
     of the patterns given in the specification. The matched host name is the
     one given on the command line.
...

[~/.ssh/config]

host *.foo.net
  user userfoo

host *.bar.net
  user userbar

-- 
  Richard Silverman
  slade@shore.net