linux mint 18.3 sshd (7.2p2) 上有两个进程启动。但是当我运行时,service ssh stop
只有子进程停止并且父进程仍在运行。因此,当我重新启动 ssh 服务时,它无法绑定 22 端口并且无法接收连接。
我阅读了有关权限分离的信息,尽管其他 linux(例如 Ubuntu)只创建一个进程,但我认为这很好。但是为什么子进程停止时父进程不会停止?以及如何让 systemd 停止这两个进程?
ssh.服务
[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
[Install]
WantedBy=multi-user.target
Alias=sshd.service
多用户.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes
服务 ssh 状态
service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Чт 2019-05-16 16:53:10 MSK; 6 days ago
Process: 4535 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 4538 (sshd)
Tasks: 2
Memory: 16.4M
CPU: 3.143s
CGroup: /system.slice/ssh.service
├─4538 /usr/sbin/sshd -D
└─4539 /usr/sbin/sshd -D