我们知道如果忘记root密码可以通过grub进入单用户模式修改密码,这样一来grub成为不安全因素,那就为grub加一把锁吧。
[root@localhost ~]# grub-md5-crypt //对grub的密码进行md5加密
Password: //123
Retype password: //123
$1$43MUd0$9w5YOOKHNAO1p0fwGc5Jj/ //123的MD5加密值
编辑:
[root@localhost ~]# vi /boot/grub/grub.conf
将 password –md5 $1$43MUd0$9w5YOOKHNAO1p0fwGc5Jj/ 添加到title上方。如果添加到title下面,等于一个启动系统密码了。
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
password –md5 $1$43MUd0$9w5YOOKHNAO1p0fwGc5Jj/
title EMOS (2.6.18-128.4.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-128.4.1.el5 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.18-128.4.1.el5.img
这个MD5值绝对是唯一的,不信可以再次加密123试试。
重启系统,进入grub看看效果吧。
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/1268.html