Damien Miller | 263d68f | 2002-06-22 00:45:50 +1000 | [diff] [blame] | 1 | Privilege separation, or privsep, is method in OpenSSH by which |
| 2 | operations that require root privilege are performed by a separate |
| 3 | privileged monitor process. Its purpose is to prevent privilege |
Damien Miller | a8e06ce | 2003-11-21 23:48:55 +1100 | [diff] [blame] | 4 | escalation by containing corruption to an unprivileged process. |
Damien Miller | 263d68f | 2002-06-22 00:45:50 +1000 | [diff] [blame] | 5 | More information is available at: |
Kevin Steves | 0228155 | 2002-05-13 03:57:04 +0000 | [diff] [blame] | 6 | http://www.citi.umich.edu/u/provos/ssh/privsep.html |
| 7 | |
Darren Tucker | 5a273a3 | 2019-09-19 15:41:23 +1000 | [diff] [blame] | 8 | Privilege separation is now mandatory. During the pre-authentication |
| 9 | phase sshd will chroot(2) to "/var/empty" and change its privileges to the |
| 10 | "sshd" user and its primary group. sshd is a pseudo-account that should |
| 11 | not be used by other daemons, and must be locked and should contain a |
Kevin Steves | 40b011c | 2002-06-26 00:43:57 +0000 | [diff] [blame] | 12 | "nologin" or invalid shell. |
| 13 | |
| 14 | You should do something like the following to prepare the privsep |
| 15 | preauth environment: |
Kevin Steves | 0228155 | 2002-05-13 03:57:04 +0000 | [diff] [blame] | 16 | |
| 17 | # mkdir /var/empty |
| 18 | # chown root:sys /var/empty |
| 19 | # chmod 755 /var/empty |
| 20 | # groupadd sshd |
Kevin Steves | 40b011c | 2002-06-26 00:43:57 +0000 | [diff] [blame] | 21 | # useradd -g sshd -c 'sshd privsep' -d /var/empty -s /bin/false sshd |
Kevin Steves | 0228155 | 2002-05-13 03:57:04 +0000 | [diff] [blame] | 22 | |
| 23 | /var/empty should not contain any files. |
| 24 | |
| 25 | configure supports the following options to change the default |
| 26 | privsep user and chroot directory: |
| 27 | |
Damien Miller | 74cc5bb | 2002-05-22 11:02:15 +1000 | [diff] [blame] | 28 | --with-privsep-path=xxx Path for privilege separation chroot |
Kevin Steves | 0228155 | 2002-05-13 03:57:04 +0000 | [diff] [blame] | 29 | --with-privsep-user=user Specify non-privileged user for privilege separation |
| 30 | |
Damien Miller | c0e014d | 2005-06-05 09:21:41 +1000 | [diff] [blame] | 31 | PAM-enabled OpenSSH is known to function with privsep on AIX, FreeBSD, |
| 32 | HP-UX (including Trusted Mode), Linux, NetBSD and Solaris. |
Kevin Steves | 0228155 | 2002-05-13 03:57:04 +0000 | [diff] [blame] | 33 | |
Darren Tucker | b6973fa | 2018-02-15 22:22:38 +1100 | [diff] [blame] | 34 | On Cygwin, Tru64 Unix and OpenServer only the pre-authentication part |
| 35 | of privsep is supported. Post-authentication privsep is disabled |
Tim Rice | 5287902 | 2004-06-27 20:50:35 -0700 | [diff] [blame] | 36 | automatically (so you won't see the additional process mentioned below). |
Ben Lindstrom | c8c548d | 2003-03-21 01:18:09 +0000 | [diff] [blame] | 37 | |
Kevin Steves | 0228155 | 2002-05-13 03:57:04 +0000 | [diff] [blame] | 38 | Note that for a normal interactive login with a shell, enabling privsep |
| 39 | will require 1 additional process per login session. |
| 40 | |
| 41 | Given the following process listing (from HP-UX): |
| 42 | |
| 43 | UID PID PPID C STIME TTY TIME COMMAND |
| 44 | root 1005 1 0 10:45:17 ? 0:08 /opt/openssh/sbin/sshd -u0 |
| 45 | root 6917 1005 0 15:19:16 ? 0:00 sshd: stevesk [priv] |
| 46 | stevesk 6919 6917 0 15:19:17 ? 0:03 sshd: stevesk@2 |
| 47 | stevesk 6921 6919 0 15:19:17 pts/2 0:00 -bash |
| 48 | |
| 49 | process 1005 is the sshd process listening for new connections. |
| 50 | process 6917 is the privileged monitor process, 6919 is the user owned |
| 51 | sshd process and 6921 is the shell process. |