如何将 GRUB 密码保护添加到操作系统加载过程中,而不是在编辑引导选项时

sla*_*oah 7 boot grub2 password

这是我的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
Run Code Online (Sandbox Code Playgroud)

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

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

谢谢!

Nul*_*let 7

我从来没有这样做过,但希望这就是你正在寻找的。

10.2.7. 设置启动密码

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

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

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

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

在 root 提示符下,使用 grub-mkpasswd-pbkdf2 加密密码:

# grub-mkpasswd-pbkdf2
Password: ****
Reenter password: ****
PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A...
Run Code Online (Sandbox Code Playgroud)

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

set superusers="root"
password_pbkdf2 root grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A...
Run Code Online (Sandbox Code Playgroud)

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

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

doc.opensuse.org - 第 10 章。引导加载程序 GRUB2:10.2.7。设置启动密码(对于 Ubuntu 略有改动)