• Home
  • Directory
  • Geeky Fun
  • MakeUseOf Guides
cool websites
RSS Twitter Facebook
Subscribe to MakeUseOf. Now, 140007 members!

How To Password Protect GRUB Entries (Linux)

By Varun Kashyap on Feb. 22nd, 2009

how-to-password-protect-grub-entries GRUB or the GRand Unified Bootloader is the bootloader commonly installed by Linux distributions on your hard disk. GRUB is responsible for showing you the menu that allows you to choose the operating system you want to boot into and also lets you tweak and control the booting options.

Awesome powers in good hands but as you probably know “with great powers come great responsibilities”, so GRUB allows you to lock down some features and boot entries to allow only the intended users to go through.

When talking of security in computer systems one often needs to analyse the situation one is in and choose the appropriate options. If you have hackers getting physical access to your computer system the GRUB security measures won’t last a second (pretty much nothing would do). Your best bet in such a situation is to keep the hard drive encrypted, or if your hard drive can be password protected, use that option.

However, the majority of us don’t have to worry about hackers with physical access as much as our not-so-computer savvy relatives and friends fiddling around with the system. That is what we have the log in passwords for (they are not secure enough for hackers, trust me!), and that is the situation where you would be wise to make use of GRUB security features.

It is also a good practice to password protect the recovery mode entries as they can be used by any user to gain root access.

GRUB security features allow you to lock down the editing of boot options accessed by pressing the ‘e’ key and they allow you to password protect selected or all boot entries.

Follow the steps below to see how to password protect GRUB entries:

  • Fire up the terminal. Type grub and press enter. The prompt would change to something like ‘grub>’.
  • Enter md5crypt at the GRUB prompt. Type in the password when prompted for and press enter. The command will return you password encrypted as an md5 hash. You will need this so make a note of it or copy to the clipboard.
  • add password to grub

  • Now we need to edit the /boot/grub/menu.lst file. You are advised to make a backup of the file before editing it in case something goes wrong.
  • password protect grub ubuntu

  • Enter the line password –md5 <the copied md5 string from step 3> before the line that reads: “BEGIN AUTOMAGIC KERNEL LIST” (actually it just needs to come before any of the boot menu entries, so you can write it anywhere as long as it is before them).
  • If you save the file at this moment without any further edits you would have locked down interactive editing in GRUB. The administrator or in this case you would have to press ‘p’ key and enter the correct password to access these advanced options.
  • If in addition you want to lock down specific menu entries so that anyone without the knowledge of the correct password cannot boot into that operating system you should add the word lock all by itself on a separate line just after the title specification for each entry in the menu.
  • The next time anyone tries to select the locked menu entry he/she will be required to enter a password before he/she can boot into the corresponding operating system.
  • To lock the recovery mode entries it is best to change the line lockalternative=false to lockalternative=true. This will lock down all future recovery mode entries as well even if you update the kernel.

What security features do you use to secure your system? Have you encrypted your hard drive? Or do you use a BIOS password? Let us know in the comments. Also check out how to add a custom background to GRUB menu

Share
stumble it!

(By) Varun Kashyap - Programmer, Blogger and Tech Enthusiast, who tweets @VarunKashyap and blogs about tips, tricks and latest on the web at TechCrazy Blog

Enjoyed the article? Subscribe to MakeUseOf to get daily updates on new cool websites and programs in your email for free. You'll also get free printable cheat sheets to your favorite programs

Your Email:




More about: boot screen . encryption . grub . password . security . ubuntu

7 Comments

2009-02-23 14:29:50
hydtech

hmm, what if someone manages to bypass or replace the Grub bootloader? then the password lock wouldn’t matter.

Reply to this comment
2009-02-27 17:39:40
JBu92

Actually, it’s much simpler than that, you can simply hit e (I think it’s w, whichever one allows you to edit the boot options) and delete the password line. Wish I’d have known that BEFORE I messed up my md5 hash (forgot the $, lol).

Reply to this comment
2009-03-06 09:14:54
JBu92

That works if you put the password on each individual entry, anyways, I’m not sure if it works w/ the lock feature.

(Comments wont nest below this level)
Reply here
2009-04-09 00:48:31
delhi
Subscribed to comments via email

sir i am facing one problem. if i boot then i will get error msg
such as Error 32:Must be authenticated
Press any key to continue…

Reply to this comment
2009-05-28 07:29:58
vickey
Subscribed to comments via email

Check the password you have entered. I think the error represents that.

Reply to this comment
2009-10-06 10:56:27
James the 1st

Two comments:

1. Varun Kashyap, the author, made it pretty clear this was to prevent would-be family and friend would-be gurus from messing where you don’t want messing. It’s certainly not to prevent a knowledgeable cracker from getting in.
2.He also made it fairly clear to do some intelligent backups before getting in to this.

Nice job…

Reply to this comment
2009-10-15 04:57:25
sensiguard

Thanks for sharing with us .very informative and interesting …keep posting :D

Reply to this comment
Reply
Click here to cancel "reply".

TopicsMUO Guides
  • Browsing
  • Cool Software
  • Web Apps
  • Lists of Tools
  • How-To Tips
  • Windows
  • Mac
  • Linux
  • Gaming
  • Mobile Apps
  • Polls
  • BitTorrentThe Easy Guide
  • iPhoneUnofficial Manual
  • ItunesThe Big Book
  • LinuxGetting Started
  • MacBeginner's Guide
  • MoviesFor Movie Addicts
  • PC BuildingThe Idiot's Guide
  • ProductivityProductivity Guide
  • PhotoshopThe Idiot's Guide
  • TwitterBest Tips & Tricks
  • More Guides
Follow us on Twitter
Be Our Friend on Facebook
MakeUseOf Staff
Editors:
  • Editor in ChiefAibek Esengulov
  • MakeUseOf Directory's EditorKaly
  • Managing EditorMark O'Neill
  • Assistant EditorJackson Chung
  • MUO WP GuyJorge Sierra
  • PDF ManualsSimon Slangen
  • Promotion & SEORyan Dube
  • Sys AdminKarl Gechlik
  • MakeUseOf NewsletterSaikat Basu
Staff Authors:
  • ( Ask The Admin )Karl Gechlik
  • Tina
  • ( Tech Crazy )Varun Kashyap
  • ( The Things I Do )Saikat Basu
  • ( simonslangen.com )Simon Slangen
  • ( BetterContent )Ryan Dube
  • ( Super Subconscious)Jeffry Thurana
  • ( Skeptic Geek )Mahendra Palsule
  • ( Tapping Thought )Dean Sherwin
  • ( Mac Photography Tips )Bakari Chavanu
  • ( timmyjohnboy.com )Tim Lenahan
  • Other Active Authors ...
© 2009 MakeUseOf . Designed by kailoon AboutContactSubmit AppWrite For UsArchivesMobile VersionDisclaimer visitor stats