How to protect GRUB by password



Create your password by typing
# grub-mkpasswd-pbkdf2

Enter your password.
This will generate a long and encrypted password.

Copy the whole generated code and Edit the file

/etc/grub.d/00_header using vi, leafpad, nano e.g
# vi /etc/grub.d/00_header
or
# sudo leafpad /etc/grub.d/00_header

Go to the end of the file.

Type the following command

cat << EOF
set superusers="username"
password_pbkdf2 username 'paste the generated code copied above here'
EOF

Save the changes and exit the editor & update grub using either of the commands

# update-grub
or
# grub-mkconfig -o /boot/grub/grub.cfg

To test the changes, reboot the system. 
If the procedure above was successful, once you select grub entry to boot, you will be prompted to enter username and password. 
Enter those credentials and your grub is secured!!!!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.