Grub2加密

前言

使用Bootloader加密,可以避免服务器在启动过程中被不怀好意的人(attckers)或者误操作带来的风险。以下介绍如何加密。

设置用户名密码及进入菜单

配置文件介绍

  1. /etc/grub.d/01_users kickstart安装过程如果指定使用该模板会建立此文件,如系统中没有可手动建立。此文件用来设置用户及密码
  2. /etc/grub.d/40_custom 用户系统菜单选项配置文件,用来限定启动系统使用的镜像、内核及用户的组织关系

设置用户及密码加密

[root@localhost ~]# cat /etc/grub.d/01_users 
cat <<EOF
set superusers="wiil"     #设置超级用户,拥有所有系统菜单进入、修改、启动权限,必须设置
password wiil 123456      #明文密码
password_pbkdf2 ok        #用户ok的加密密码,后面有介绍如何加密   
grub.pbkdf2.sha512.10000.5429F8134584EB531B9C5BFF59ADBFD4FB3751CA19FEB9DA1003A3BBC5638FBE9288D1D6B3F303306D0891EC7710CC526CBAEDBF35AD05F4245C3147100CC34A.72504215A4B0A19F2246CCDDD4D40E12B5BA0287D053B89607E7174B79ADD787745C036F7CDCBA1A2A184CCCA2720FD1A6682ED55CB05ED654CE92209A4673DD
EOF

[root@localhost ~]#

设置菜单入口加密

[root@localhost ~]# cat /etc/grub.d/40_custom 
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Red Hat Enterprise Linux Server 7.1 (Test)' --users wiil {
set root=(hd0,msdos1)
linux16 /vmlinuz-3.10.0-229.el7.x86_64 root=/dev/mapper/rhel-root ro rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root rhgb quiet
initrd16 /initramfs-3.10.0-229.el7.x86_64.img
}

menuentry 'Red Hat Enterprise Linux Server 7.1 (OK)' --users ok {
set root=(hd0,msdos1)
linux16 /vmlinuz-3.10.0-229.el7.x86_64 root=/dev/mapper/rhel-root ro rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root rhgb quiet
initrd16 /initramfs-3.10.0-229.el7.x86_64.img

生成grub.cfg

1.基于BIOS的服务器

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

2.基于EFI的服务器

 grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

备注

1.密码加密

[root@localhost ~]# grub2-mkpasswd-pbkdf2 
Enter password: 
Reenter password: 
PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.F42D8CCA10D20EE96CCCB8CF732593DCD5BAB8ABA02FECAD7AF89146023CC4877A3EDF57C3D470DEFE71A9363F5386E899538979F41E3089720C356CD04AACBE.043B48C6C0C364740F1D6A6A78749E37FE2AB4C7D4B6A24783817947BA920BC758EBACFC2154360DB026D489E6BE8E041A64A4149AFFF42FE8F76EC2CB3B3E75
[root@localhost ~]# 

2.使用密码加密必须有superuser,仅有普通用户grub加密不生效

3.官方rh7 grub2 encrypt 参考链接:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sec-GRUB_2_Password_Protection.html

4.拥有–unrestricted属性的菜单,任何人都可以boot,但是不能‘e’,即修改启动参数。并且所有菜单入口的修改均需要user/password。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值