在 Linux 中为单用户模式设置密码增加了 Linux 机器的安全性。
如果有人物理访问服务器并重新启动服务器,然后尝试从单用户模式更改 root 密码。
在这种情况下,如果在单用户模式下设置了密码,则必须先输入 root 密码,然后才能重置 root 密码。
注意 - 在类似 Debian 的操作系统中,当引导到单用户模式或者恢复模式时需要 root 密码。
但是 RHEL 和 CentOS 允许从控制台进入单用户模式而无需密码。
在 CentOS/RHEL 5.x 上为单用户模式设置密码
编辑文件 /etc/inittab ,在 initdefault 行上方添加“su:S:wait:/sbin/sulogin”,如下所示:
# vi /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # Modified for RHS Linux by Marc Ewing and Donnie Barnes # # Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # su:S:wait:/sbin/sulogin id:5:initdefault:
www. On IT Road .com
在 CentOS/RHEL 6.x 上为单用户模式设置密码
编辑文件 /etc/sysconfig/init 并将“SINGLE=/sbin/sushell”替换为“/sbin/sulogin”,如下所示:
# What ttys should gettys be started on? ACTIVE_CONSOLES=/dev/tty[1-6] # Set to '/sbin/sulogin' to prompt for password on single-user mode # Set to '/sbin/sushell' otherwise SINGLE=/sbin/sulogin
日期:2020-09-17 00:12:43 来源:oir作者:oir