为什么sshd(openssh)每个连接创建两个进程?

Modified on: Tue, 16 Jul 2019 13:40:02 +0800

登录前

$ ps -elf | grep sshd
5 S root     26135     1  0  80   0 - 13115 ?      17:26 ?        00:00:00 /usr/sbin/sshd
0 S test     26480 21337  0  80   0 -  4154 -      18:41 pts/27   00:00:00 grep --colour=auto sshd

登录后

$ ps -elf | grep sshd
5 S root     26135     1  0  80   0 - 13115 ?      17:26 ?        00:00:00 /usr/sbin/sshd
4 S root     26577 26135  0  80   0 - 24204 ?      18:42 ?        00:00:00 sshd: test [priv] 
5 S test     26582 26577  0  80   0 - 24204 ?      18:42 ?        00:00:00 sshd: test@pts/30 
0 S test     26653 21337  0  80   0 -  4155 -      18:42 pts/27   00:00:00 grep --colour=auto sshd

这两个过程是什么?

4 S root     26577 26135  0  80   0 - 24204 ?      18:42 ?        00:00:00 sshd: test [priv] 
5 S test     26582 26577  0  80   0 - 24204 ?      18:42 ?        00:00:00 sshd: test@pts/30

谢谢,

作者:wei

最佳答案

权限分离 - 一个保留root权限的进程,只执行root可以执行的操作,另一个执行其他操作。

在提出此问题时,权限分离由sshd_config中的选项控制,sshd_config手册页解释了它的用途。在7.5版中强制要求权限分离,因此该选项及其文档已不复存在。如果存在任何此类文档,我不知道在哪里可以找到特权分离功能的规范文档。

删除前的手册页项的最后一个版本说:

UsePrivilegeSeparation Specifies whether sshd(8) separates privileges by creating an unprivileged child process to deal with incoming network traffic. After successful authentication, another process will be created that has the privilege of the authenticated user. The goal of privilege separation is to prevent privilege escalation by con- taining any corruption within the unprivileged processes. The argument must be yes, no, or sandbox. If UsePrivilegeSeparation is set to sandbox then the pre-authentication unprivileged process is subject to additional restrictions. The default is sandbox.


相关问答

添加新评论