First you need to encrypt your password. You can do that by running the "md5crypt" command from Within the GRUB shell. Then you need to add a "password" command to grub.conf that uses that Encrypted password, like this:
#grub-md5-crypt >grub Press Enter
Note: - Nothing will be appearing on your screen so don't hesitate.
Type The Password such as redhat press enter.
Retype the password redhat press enter.
# vi /root/grub /etc/grub.conf
This command will open both the file in vi editor as shown in the above example.
Now copy the encrypted passwords using yy.
and type n (This will switch you to the next file /etc/grub.conf).
And after the splashimage=(hd,0,0) line : -
Press pp to paste the encryped password from the previous file.
And add the following line before the encrypted password like this: -
password --md5 $1$I2w2s1$EPZtrLn/h2M4qfh48ZL8O0
Save and exit and reboot your system.