miv*_*ivk 11
这对我有用:
apt-get install libpam-systemd dbus
Run Code Online (Sandbox Code Playgroud)
还要确保UsePAM yes
您的 ssh 配置中有。
grep -i UsePAM /etc/ssh/sshd_config
Run Code Online (Sandbox Code Playgroud)
不幸的是,您需要重新启动才能使解决方案生效...
关于serverfault 的详细解释。
看起来这是systemd
当前在错误 #751636下跟踪的问题。
当主机关闭或重新启动时,systemd
可能会在终止 ssh 会话之前关闭网络。
提供了几种解决方案,但没有具体的解决方案:
使用acpid/acpi-support-base
来处理电源事件及以下添加到/etc/acpi/powerbtn-acpi-support.sh
else
- # Normal handling.
- /sbin/shutdown -h -P now "Power button pressed"
+
+ if [ -x /bin/systemctl ] ; then
+ echo "\nPower button pressed\nThe system is going down for system halt NOW!" |\
+ /usr/bin/wall -n
+ /bin/systemctl --force poweroff
+ else
+ # Normal handling.
+ /sbin/shutdown -h -P now "Power button pressed"
+ fi
+
fi
Run Code Online (Sandbox Code Playgroud)
然后在你的~/.bashrc
:
alias reboot='echo "The system is going down for system reboot NOW!" |\
/usr/bin/wall -n ; /bin/systemctl --force reboot'
alias poweroff='echo "The system is going down for system halt NOW!" |\
/usr/bin/wall -n ; /bin/systemctl --force poweroff'
Run Code Online (Sandbox Code Playgroud)/etc/systemd/system/ssh-user-sessions.service
在其中创建以下内容:
[Unit]
Description=Shutdown all ssh sessions before network
After=network.target
[Service]
TimeoutStartSec=0
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecStop=/usr/bin/killall sshd
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
10683 次 |
最近记录: |