文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Grub2启动加密

Grub2启动加密

时间:2010-10-09  来源:fuleru

 

需求:在grub2菜单有选项A、及B。A是默认启动的项,如果用户选择了B,则需要输入密码才能启动。可以做到么?注意,不是编辑grub2的菜单加密。

终于实现此功能:

    系统是Debian GNU/Linux squeeze/sid,编辑/etc/grub.d/00_header文件,增加
下面的内容:

 

cat << EOF
set superusers="ct"
password ct ct@xxer
EOF
#设置用户ct与密码ct@xxer

cat << EOF
if keystatus; then
  if keystatus --shift; then
    set timeout=-1
  else
    set timeout=0
  fi
else
  if sleep --interruptible 3 ; then
    set timeout=0
  fi
fi
EOF
#设置shift键

      然后再在/etc/grub.d/40_custom 文件后面增加下面的内容:


 

menuentry "B" --users ct {
insmod ntfs
set root=(hd0,msdos6)
set isofile="/isos/db_recovery.iso"
loopback loop $isofile
linux (loop)/live/vmlinuz boot=live union=aufs noswap noprompt vga=788 ip=frommedia toram=filesystem.squashfs findiso=$isofile
initrd (loop)/live/initrd.img
}

 

    注意“--users ct”这一段

然后update-grub2,更新grub2配置。


这样设置后,系统默认启动设置的项。

当有需要时,在grub2启动时,按住shift进入grub2菜单,如果需要编辑grub菜单,则需要grub2设置的用户跟密码;如果想启动Debian Recovery项,也是需要密码。
这样的密码是明文的,如果密码是使用grub-mkpasswd-pbkdf2生成,则把生成的串值代替成password段是密码的那段,如password_pbkdf2 ct .....

参考内容:
http://members.iinet.net/~herman546/p20.html
http://ubuntuforums.org/showthread.php?t=1369019

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载