如何将GRUB密码保护添加到OS加载进程,而不是在编辑引导选项时

这是我的grub.conf文件的当前内容。

 # 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/sda3 # initrd /initrd-[generic-]version.img #boot=/dev/sda password --md5 $1$Xw8nQ1$/bLNi3DsrtmtKAgd.pBe0 default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu # title My OS 1234 (2.6.32-358.el6.i686) title Group 10 Linux Server root (hd0,0) kernel /vmlinuz-2.6.32-358.el6.i686 ro root=UUID=f9d7b7b0-3035-4c44-b7e2-97f995e995fb rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-358.el6.i686.img 

仅当用户尝试编辑GRUB条目的引导选项时,才会提示用户输入密码。

我需要更改此设置,以便在加载操作系统之前提示用户输入密码。

谢谢!

我从来没有这样做过,但希望这就是你要找的东西。

10.2.7。 设置启动密码

即使在引导操作系统之前,GRUB2也可以访问文件系统。 没有root权限的用户可以访问Linux系统中的文件,一旦系统启动,他们就无法访问这些文件。 要阻止此类访问或阻止用户引导某些操作系统,请设置引导密码。

[重要]启动密码和启动画面:

如果您使用GRUB2的启动密码,则不会显示通常的启动画面。

作为root用户,按以下步骤设置启动密码:

在根提示符下,使用grub2-mkpasswd-pbkdf2加密密码:

 # grub2-mkpasswd-pbkdf2 Password: **** Reenter password: **** PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A... 

将加密的长字符串与set superusers命令一起粘贴到文件/etc/grub.d/40_custom中。 请记住将注释行保留在开头:

 set superusers="root" password_pbkdf2 root grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A... 

运行grub2-mkconfig -o /boot/grub2/grub.cfg将更改导入主配置文件。

重新启动后,在尝试启动任何菜单项时,系统将提示您输入用户名和密码。 输入root和您在grub2-mkpasswd-pbkdf2命令期间输入的密码。 如果凭据正确,系统将引导选定的引导条目。

doc.opensuse.org – 第10章引导加载程序GRUB2:10.2.7。 设置启动密码