How to Give Your GRUB Menu a Password

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

How to Give Your GRUB Menu a Password

#1 Post by rcrsn51 »

Before starting this procedure, you should set up a temporary back door so you can still boot into your system if you make a mistake. Open your GRUB menu.lst file and make a duplicate copy of your current entry. Once you have the password-protected entry working, you can delete the second entry.

1. Open a terminal and type

Code: Select all

grub
This loads the GRUB emulator.

2. Type

Code: Select all

md5crypt
Type in the password you want to use. GRUB will return the encrypted version. Leave this window open for now.

3. Open your menu.lst file in a text editor. Insert a blank line after the title line and add

Code: Select all

password --md5  abcdefg
using the encrypted password from Step 2. Since you probably don't want to type this by hand, you can use the middle-click technique. Put your mouse in the Step 2 window and highlight the password. Then place your cursor in the Step 3 window and middle-click to paste the code in. Double-check that you have copied the password correctly.

4. Save the file and reboot.

If you somehow manage to completely lock up your system, you can always boot off the Live CD, mount your Puppy partition, open the menu.lst file and delete the password line.

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#2 Post by bigpup »

Do you know if this will work with a Grub4dos menu.lst?

User avatar
r1tz
Posts: 162
Joined: Thu 09 Sep 2010, 05:19
Location: In #puppylinux (IRC)

#3 Post by r1tz »

Cool! this is interesting :)

User avatar
KusaNoKaito
Posts: 99
Joined: Fri 19 Feb 2010, 22:52
Location: Florida
Contact:

#4 Post by KusaNoKaito »

Wow. never knew one could do this. Thank you "rcrsn5" for posting.

gerry
Posts: 986
Joined: Thu 26 Jul 2007, 21:49
Location: England

#5 Post by gerry »

Can one do this in Grub2?

Gerry

shadower_sc
Posts: 136
Joined: Wed 21 Apr 2010, 23:03
Location: Texas

Password for Grub2

#6 Post by shadower_sc »

Thanks rcrsn51 :) I wouldn't have thought about it, if you hadn't posted it. :D It looks to be fairly straight forward too.

There is a fairly lengthy and what looks to be a good explanation for Grub2 password protection on the Ubutnu forums here: http://ubuntuforums.org/showthread.php?t=1369019

It should work with any Linux Distribution using Grub 2. Same with rcrsn51's explanation for Legacy Grub.

I am sure you could apply either version to a grub4dos installl with a bit of adapting. Just make sure you know what version of grub your grub4dos is using and try to follow the guide for that version.

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Grub4dos menu.lst

#7 Post by shinobar »

bigpup wrote:Do you know if this will work with a Grub4dos menu.lst?
Grub4Dos config > Grub4Dos Guide > Password Protecting Boot Options
I have not yet tried.
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

User avatar
Digger
Posts: 6
Joined: Sun 16 Jan 2011, 16:48

#8 Post by Digger »

Thanks for this great tip.

It works great for me when I boot to Puppeee on my eee PC 901, but I am not getting a password query when booting into FREEDOS (on a different SSD on the same machine - Puppeee is on sda1 and FREEDOS is on sdb1).

Here is my menu.lst file:

Code: Select all

# GRUB configuration file '/boot/grub/menu.lst'.
# generated by 'grubconfig'.  Tue Mar  1 22:34:39 2011
#
# The backup copy of the MBR for drive '/dev/sda' is
# here '/boot/grub/mbr.sda.32728'.  You can restore it like this.
# dd if=/boot/grub/mbr.sda.32728 of=/dev/sda bs=512 count=1
#
hiddenmenu
default=0
timeout=0
# Start GRUB global section
#timeout 30
color light-gray/blue black/light-gray
# End GRUB global section
# Linux bootable partition config begins
  title Linux (on /dev/sda1)
  password --md5 booboo
  root (hd0,0)
  kernel /boot/vmlinuz root=/dev/sda1 ro vga=normal
# Linux bootable partition config ends
# Other bootable partition config begins
  title FreeDOS
  password --md5 booboo1
  root (hd1,0)
  makeactive
  chainloader  +1
# Other bootable partition config ends
# Linux bootable partition config begins
  title Linux (on /dev/sdb2)
  root (hd1,1)
  kernel /boot/vmlinuz root=/dev/sdb2 ro vga=normal
# Linux bootable partition config ends
title Install GRUB to floppy disk (on /dev/fd0)
pause Insert a formatted floppy disk and press enter.
root (hd0,0)
setup (fd0)
pause Press enter to continue.
title Install GRUB to Linux partition (on /dev/sda1)
root (hd0,0)
setup (hd0,0)
pause Press enter to continue.
title -     For help press 'c', then type: 'help'
root (hd0)
title -     For usage examples, type: 'cat /boot/grub/usage.txt'
root (hd0)
I'm wondering why the line showing the "booboo1" password is not causing a password query to be generated when I boot into FREEDOS.

What am I doing wrong?

TIA!

User avatar
stiginge
Posts: 420
Joined: Thu 22 Mar 2007, 10:10
Location: Kerry, Ireland

#9 Post by stiginge »

Nice one rcr, got it goin no probs on 5.1.1.56
Buy silver, crash JPMorgan

Post Reply