grub-mkpasswd-pbkdf2

复制整个生成的代码。

编辑文件/etc/grub.d/00_header

nano /etc/grub.d/00_header

转到文件的末尾,输入以下:

cat << EOF

set superusers="username"

password_pbkdf2 username 'paste the generated code copied above here'

EOF

注:username意思是用户名(两处都需要修改),paste the generated code copied above here意思是粘贴上面复制的生成代码(即'grub.pbkdf2.sha512.10000.。。。。。。'部分)。EOF后面不能有空格。

保存更改并退出编辑器并使用以下命令更新grub:

update-grub

提示如下:

Found linux image: /boot/vmlinuz-6.1.0-29-cloud-amd64
Found initrd image: /boot/initrd.img-6.1.0-29-cloud-amd64
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done

或者:

grub-mkconfig -o /boot/grub/grub.cfg

要测试更改,请重新引导系统,如果上述操作过程成功,一旦选择要引导的grub条目,系统将提示你输入用户名和密码,输入那些信息,这可以保证grub更加安全。

最后修改:2025 年 03 月 03 日
如果觉得我的文章对你有用,请随意赞赏