5.19. LILO 和lilo.conf文件

LILO 是 Linux 最常用的引导加载程序。它管理引导过程,可以从软盘、硬盘启动 Linux 内核镜像,甚至可以充当其他操作系统的引导管理器。LILO 在 Linux 系统中非常重要,因此我们必须尽最大努力保护它。LILO 最重要的配置文件是lilo.conf文件,它位于/etc目录中。通过此文件,我们可以配置和提高 LILO 程序和 Linux 系统的安全性。以下是三个重要的选项,它们将提高我们宝贵的 LILO 程序的安全性。

添加:timeout=00

此选项控制 LILO 在启动到默认选择之前等待用户输入的时间(以秒为单位)。C2 安全性的要求之一是将此间隔设置为 0,除非系统双启动其他内容。

添加:restricted

仅当在命令行上指定参数(例如 linux single)时,此选项才会要求输入密码。“restricted”选项只能与“password”选项一起使用。请确保在每个镜像上都使用此选项。

添加:password=<password>

当尝试以单用户模式加载 Linux 系统时,此选项会要求用户输入密码。密码始终区分大小写,另请确保/etc/lilo.conf文件不再是全局可读的,否则任何用户都将能够读取密码。

受保护的lilo.conf文件示例。

  1. 编辑 lilo.conf 文件 vi/etc/lilo.conf并添加或更改如上所示的三个选项
                  boot=/dev/sda
                  map=/boot/map
                  install=/boot/boot.b
                  prompt
                  timeout=00 � change this line to 00.
                  Default=linux
                  restricted � add this line.
                  password=<password>  (1)
                  image=/boot/vmlinuz-2.2.12-20
                  label=linux
                  initrd=/boot/initrd-2.2.12-10.img
                  root=/dev/sda6
                  read-only
                  

    (1)
    添加此行并输入您的密码。

  2. 因为配置文件/etc/lilo.conf现在包含未加密的密码,所以它应该只对超级用户 root 可读。
                  [root@deep] /# chmod 600  /etc/lilo.conf will be no longer world readable.
                  

  3. 现在我们必须更新我们的配置文件/etc/lilo.conf以使更改生效。
                  [root@deep] /# /sbin/lilo -v to update the lilo.conf file.
                  

  4. 您可以采取另一项安全措施来保护lilo.conf文件是将其设置为不可变,使用 chattr 命令。要将文件设置为不可变,只需使用命令
                  [root@deep] /# chattr +i /etc/lilo.conf
                  
    这将防止对lilo.conf文件的任何意外或其他更改。如果您希望修改lilo.conf文件,您需要取消设置不可变标志:要取消设置不可变标志,请使用命令
                  [root@deep] /# chattr -i /etc/lilo.conf