Wednesday, March 24, 2010

Linux: Assigning a password to GRUB

How to assign a password to GRUB after Linux OS is installed?

1. Login to the system as 'root' user.

2. Execute the command
bash-3.0# grub

Now we can observe the change in the prompt


grub> md5crypt
This command will prompt for password. Type the password. It'll generate the encrypted password.


GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]

grub> md5crypt

Password: ******
Encrypted: $1$DDD2V/$MEJHXqlrloKA6gO1PCc3x1

3. Now make a note or copy the encrypted password, quit from grub.

grub> quit.

4. Now edit the file /etc/grub.conf as follows.
The password has to edited as follows:


bash-3.0# vi /etc/grub.conf

# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda2
# initrd /initrd-version.img
password --md5 $1$DDD2V/$MEJHXqlrloKA6gO1PCc3x1
title Red Hat Enterprise Linux Server (2.6.18-8.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-8.el5.img


5. Save & quite.

That's it.

No comments:

Post a Comment