Article Title: how to add a password to Grub. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The purpose is to prevent others from modifying grub and start it in single-user mode.
You only need to modify the grub Startup File to add a line of password keywords, which can be stored in plaintext or after MD5 encryption. The following describes how to use MD5 encryption.
1. First Use/sbin/grub-md5-crypt to generate an MD5 password string
/Sbin/grub-md5-crypt Password: Retype password: $1 $ oWpTe $/MWUUYbBlF.2RUZK8nbWU0 |
The original password is "abc ".
2. Modify the grub. conf file
Default = 0 Timeout = 5 Splashimage = (hd0, 0)/boot/grub/splash.xpm.gz Hiddenmenu Password -- md5 $1 $ oWpTe $/MWUUYbBlF.2RUZK8nbWU0 Title Red Hat Enterprise Linux AS (2.6.x-xx. EL) ......... |
Note that the password must be added between the splashimage and title; otherwise, it cannot take effect.
Then restart the machine and you will find that you want to modify the grub menu. You must press P and enter the correct password to continue.
Add a grub. conf method using sed to modify all servers in batches.
GRUB =/boot/grub. conf TEMP =/tmp/grub. conf Grep-v password $ GRUB & cat $ TEMP | sed-e's/hiddenmenu \ npassword -- Md5 \ $1 \ $ oWpTe \ $ \/MWUUYbBlF.2RUZK8nbWU0/G'> $ GRUB |