I'm confused about how sshd drops privs for incoming connections. I found this page which was very informative on a high level:
http://www.citi.umich.edu/u/provos/ssh/privsep.html
But I don't understand how the child of privileged sshd is unprivileged.
In my debug below privileged sshd is 28389 and calls clone() to create 29266, the unprivileged child. When I use ps to display the UID/EUID of the pids 29268 is UID 1002 as expected, but 29266, the unprivileged child of sshd, is zero, which seems to contradict the link above which says 'This is achieved by changing its uid/gid to an unused user'.
woOt@host:~$ sudo strace -p 28389 -e trace=clone
Process 28389 attached - interrupt to quit
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fb7076d5a90) = 29266
^CProcess 28389 detached
woOt@host:~$
woOt@host:~$
woOt@host:~$ ps auxf | grep sshd
root 28389 0.0 0.0 49944 1244 ? Ss 18:15 0:00 /usr/sbin/sshd
root 29266 0.0 0.2 54576 3308 ? Ss 18:37 0:00 \_ sshd: test [priv]
test 29268 0.0 0.0 54576 1440 ? S 18:37 0:00 \_ sshd: test@pts/2
woOt@host:~$
woOt@host:~$
woOt@host:~$ ps -eo pid,uid,euid | egrep 'PID|28389|29266|29268'
PID UID EUID
28389 0 0
29266 0 0
29268 1002 1002
woOt@host:~$
woOt@host:~$
woOt@host:~$ grep 1002 /etc/passwd
test:x:1002:1003:,,,:/home/test:/bin/bash
woOt@host:~$
edited question to correctly illustrate:
unprivileged child (2406) of monitor process (2405)
root 2370 0.0 1.1 55592 5524 ? Ss 00:12 0:00 /usr/sbin/sshd -D root 2405 0.0 1.1 59008 5720 ? Ss 00:12 0:00 \_ sshd: test [priv] sshd 2406 0.0 0.6 56936 3072 ? S 00:12 0:00 \_ sshd: test [net]
and user privileged child (2419) of monitor process post-auth:
root 2370 0.0 1.1 55592 5524 ? Ss 00:12 0:00 /usr/sbin/sshd -D root 2405 0.0 1.1 60224 5756 ? Ss 00:12 0:00 \_ sshd: test [priv] test 2419 0.0 0.7 60224 3888 ? S 00:12 0:00 \_ sshd: test@pts/1
appreciate the answers, thanks