当前位置:首页>Linux>2.3 Linux系统-grub加密

2.3 Linux系统-grub加密

  • 2026-09-02 19:31:16
2.3 Linux系统-grub加密

3 加密grub

七版本

设置grub密码,编辑配置文件,启用重启后,grub菜单按e进入编辑,ctrl+x启动

[root@localhost ~]# grub2-mkpasswd-pbkdf2    #设置grub密码输入口令:Reenter password: PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.E605CEA1755860612BAE4B04A72DDDD913E0E6E268D434CAC1F14BED63C83F3D9FCDC7BF15B4E1CFF0DB9DB12AABB79833460032D2122477BC5B1C59F26090C3.C9DE311C026D3B3B8EF9D4549BE9AF8A238CCAC54A224DF854A7384A60F823601517D985C06CA11BE7D0CEE1AF42F5CBFA69DFB3DFCC61CD1651B871EB603AEF[root@localhost ~]# vim /etc/grub.d/00_header   #编辑配置文件#在最后新加入cat <<EOFset superusers='yq'password_pbkdf2 yq grub.pbkdf2.sha512.10000.E605CEA1755860612BAE4B04A72DDDD913E0E6E268D434CAC1F14BED63C83F3D9FCDC7BF15B4E1CFF0DB9DB12AABB79833460032D2122477BC5B1C59F26090C3.C9DE311C026D3B3B8EF9D4549BE9AF8A238CCAC54A224DF854A7384A60F823601517D985C06CA11BE7D0CEE1AF42F5CBFA69DFB3DFCC61CD1651B871EB603AEFEOF[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg   #启用Generating grub configuration file ...Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.imgFound linux image: /boot/vmlinuz-0-rescue-51b463e7803f477d9f46aa6163e1f85eFound initrd image: /boot/initramfs-0-rescue-51b463e7803f477d9f46aa6163e1f85e.imgdone

删除grub密码:

  将/etc/grub.d/00_header文件中的最后删除  grub2-mkconfig  -o /boot/grub2/grub.cfg  #启用配置

六版本

创建密码、修改配置文件、重启、grub菜单按p、输入密码进入编辑、b重启

[root@localhost ~]# grub-md5-crypt    #创建加密码Password: Retype password: $1$VtlyA$ZA6Xwn.O0.oXPFQLTHS0F.[root@localhost ~]# vim /boot/grub/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/sdadefault=0timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenupassword --md5 $1$VtlyA$ZA6Xwn.O0.oXPFQLTHS0F.    #在title前加入passwordtitle CentOS 6 (2.6.32-642.el6.x86_64)        root (hd0,0)        kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=UUID=b8391479-c2e4-4116-8166-c9da7736e758 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet        initrd /initramfs-2.6.32-642.el6.x86_64.img

删除grub密码:

删除grub密码:   进入/boot/grub/grub.cfg删除passwrod整行、重启即生效

最新文章

随机文章