xref: /freebsd/crypto/openssh/README.privsep (revision 043840df5be0cf8490b48a08fe6d9c316f473f58)
183d2307dSDag-Erling SmørgravPrivilege separation, or privsep, is method in OpenSSH by which
283d2307dSDag-Erling Smørgravoperations that require root privilege are performed by a separate
383d2307dSDag-Erling Smørgravprivileged monitor process.  Its purpose is to prevent privilege
483d2307dSDag-Erling Smørgravescalation by containing corruption to an unprivileged process.
583d2307dSDag-Erling SmørgravMore information is available at:
683d2307dSDag-Erling Smørgrav	http://www.citi.umich.edu/u/provos/ssh/privsep.html
783d2307dSDag-Erling Smørgrav
883d2307dSDag-Erling SmørgravPrivilege separation is now enabled by default; see the
983d2307dSDag-Erling SmørgravUsePrivilegeSeparation option in sshd_config(5).
1083d2307dSDag-Erling Smørgrav
1183d2307dSDag-Erling SmørgravOn systems which lack mmap or anonymous (MAP_ANON) memory mapping,
1283d2307dSDag-Erling Smørgravcompression must be disabled in order for privilege separation to
1383d2307dSDag-Erling Smørgravfunction.
1483d2307dSDag-Erling Smørgrav
15ee21a45fSDag-Erling SmørgravWhen privsep is enabled, during the pre-authentication phase sshd will
1683d2307dSDag-Erling Smørgravchroot(2) to "/var/empty" and change its privileges to the "sshd" user
17ee21a45fSDag-Erling Smørgravand its primary group.  sshd is a pseudo-account that should not be
18ee21a45fSDag-Erling Smørgravused by other daemons, and must be locked and should contain a
19ee21a45fSDag-Erling Smørgrav"nologin" or invalid shell.
20ee21a45fSDag-Erling Smørgrav
21ee21a45fSDag-Erling SmørgravYou should do something like the following to prepare the privsep
22ee21a45fSDag-Erling Smørgravpreauth environment:
2383d2307dSDag-Erling Smørgrav
2483d2307dSDag-Erling Smørgrav	# mkdir /var/empty
2583d2307dSDag-Erling Smørgrav	# chown root:sys /var/empty
2683d2307dSDag-Erling Smørgrav	# chmod 755 /var/empty
2783d2307dSDag-Erling Smørgrav	# groupadd sshd
28ee21a45fSDag-Erling Smørgrav	# useradd -g sshd -c 'sshd privsep' -d /var/empty -s /bin/false sshd
2983d2307dSDag-Erling Smørgrav
3083d2307dSDag-Erling Smørgrav/var/empty should not contain any files.
3183d2307dSDag-Erling Smørgrav
3283d2307dSDag-Erling Smørgravconfigure supports the following options to change the default
3383d2307dSDag-Erling Smørgravprivsep user and chroot directory:
3483d2307dSDag-Erling Smørgrav
3583d2307dSDag-Erling Smørgrav  --with-privsep-path=xxx Path for privilege separation chroot
3683d2307dSDag-Erling Smørgrav  --with-privsep-user=user Specify non-privileged user for privilege separation
3783d2307dSDag-Erling Smørgrav
38ee21a45fSDag-Erling SmørgravPrivsep requires operating system support for file descriptor passing.
39ee21a45fSDag-Erling SmørgravCompression will be disabled on systems without a working mmap MAP_ANON.
4083d2307dSDag-Erling Smørgrav
41043840dfSDag-Erling SmørgravPAM-enabled OpenSSH is known to function with privsep on AIX, FreeBSD,
42043840dfSDag-Erling SmørgravHP-UX (including Trusted Mode), Linux, NetBSD and Solaris.
4383d2307dSDag-Erling Smørgrav
44d74d50a8SDag-Erling SmørgravOn Cygwin, Tru64 Unix, OpenServer, and Unicos only the pre-authentication
45d74d50a8SDag-Erling Smørgravpart of privsep is supported.  Post-authentication privsep is disabled
46d74d50a8SDag-Erling Smørgravautomatically (so you won't see the additional process mentioned below).
47d0c8c0bcSDag-Erling Smørgrav
4883d2307dSDag-Erling SmørgravNote that for a normal interactive login with a shell, enabling privsep
4983d2307dSDag-Erling Smørgravwill require 1 additional process per login session.
5083d2307dSDag-Erling Smørgrav
5183d2307dSDag-Erling SmørgravGiven the following process listing (from HP-UX):
5283d2307dSDag-Erling Smørgrav
5383d2307dSDag-Erling Smørgrav     UID   PID  PPID  C    STIME TTY       TIME COMMAND
5483d2307dSDag-Erling Smørgrav    root  1005     1  0 10:45:17 ?         0:08 /opt/openssh/sbin/sshd -u0
5583d2307dSDag-Erling Smørgrav    root  6917  1005  0 15:19:16 ?         0:00 sshd: stevesk [priv]
5683d2307dSDag-Erling Smørgrav stevesk  6919  6917  0 15:19:17 ?         0:03 sshd: stevesk@2
5783d2307dSDag-Erling Smørgrav stevesk  6921  6919  0 15:19:17 pts/2     0:00 -bash
5883d2307dSDag-Erling Smørgrav
5983d2307dSDag-Erling Smørgravprocess 1005 is the sshd process listening for new connections.
6083d2307dSDag-Erling Smørgravprocess 6917 is the privileged monitor process, 6919 is the user owned
6183d2307dSDag-Erling Smørgravsshd process and 6921 is the shell process.
6283d2307dSDag-Erling Smørgrav
63043840dfSDag-Erling Smørgrav$Id: README.privsep,v 1.16 2005/06/04 23:21:41 djm Exp $
64