Ubuntu 10.10 Server : Grub 2 Password Protection

Here are some steps to password protect recovery mode menu entries in Grub menu in Ubuntu 10.10.

  1. Install dependancies :
  2. sudo apt-get install grub-common

  3. Add the following the bottom of /etc/grub.d/00_header.  Replace myUser with the authorized user name and myPassword with the corresponding password.

    cat << EOF
    set superusers=”myUser”
    password myUser myPassword
    EOF

  4. To password protect the Recovery Mode option, edit /etc/grub.d/10_linux :
    Replace

    printf “menuentry ‘${title}’ ${CLASS} {\n” “${os}” “${version}”

    With

    if ${recovery} ; then
    printf “menuentry ‘${title}’ –users user1 ${CLASS} {\n” “${os}” “${version}”
    else
    printf “menuentry ‘${title}’ ${CLASS} {\n” “${os}” “${version}”
    fi

  5. Execute sudo grub-mkconfig -o /boot/grub/grub.cfg.

If you want to encrypt your password in the configuration file, run the command grub-mkpasswd_pbkdf2. It will ask to type your password twice and will return the encrypted value. Replace the password your previously typed in the file /etc/grub.d/00_header with that long value…

References :

Leave a Reply

Your email address will not be published. Required fields are marked *