Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Oct 2004 14:10:31 -0500
From:      Mark Johnston <mjohnston@skyweb.ca>
To:        Mark Skurzynski <mark@lomag.net>, freebsd-security@freebsd.org
Subject:   Re: Question restricting ssh access for some users only
Message-ID:  <200410071410.31964.mjohnston@skyweb.ca>
In-Reply-To: <20041007185425.GB25539@yem.eng.utah.edu>
References:  <cvuam0t1l2u7npnigk6oqrlq288hlu0mgn@4ax.com> <080b01c4ac9e$90584250$0a13a8c0@lomag.net> <20041007185425.GB25539@yem.eng.utah.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Mark Ogden <ogden@eng.utah.edu> wrote:
> Mark Skurzynski on Thu, Oct 07, 2004 at 02:50:49PM -0400 wrote:
> > I normally don't reply here however the simple solution is to run a 2nd
> > instance of sshd on any random port you choose, ie. "sshd -f
> > /etc/ssh/sshd_config_private" or whatever you choose. You could then
> > easily firewall that port and only allow specific IP's to connnect.
>
> Yes, that was our second idea. But we feel theres got to be a better
> way.

Seems appropriate that a third Mark should chip in here: there is.  You can 
use ~/.ssh/authorized_keys to add restrictions, one of which is "from":

     from="pattern-list"
             Specifies that in addition to public key authentication, the
             canonical name of the remote host must be present in the comma-
             separated list of patterns (`*' and `'?  serve as wildcards).
             The list may also contain patterns negated by prefixing them with
             `'!; if the canonical host name matches a negated pattern, the
             key is not accepted.  The purpose of this option is to optionally
             increase security: public key authentication by itself does not
             trust the network or name servers or anything (but the key); how-
             ever, if somebody somehow steals the key, the key permits an
             intruder to log in from anywhere in the world.  This additional
             option makes using a stolen key more difficult (name servers
             and/or routers would have to be compromised in addition to just
             the key).

Apply that to the only key you allow to log in for root, and then set 
PermitRootLogin to "without-password", heeding the warning in sshd_config(5) 
about ChallengeResponseAuthentication.

I would still encourage you to look at Per Engelbrecht's sudo suggestion; you 
will very likely want the logging that it provides.  However, you should be 
able to do exactly what you want with this.

Mark



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200410071410.31964.mjohnston>