Friday, 4 May 2012

Grub & Single user mode password Protected

Hi,
Today i am working on my pc and i thought if i set password for single user mode then any one can’t entered inside and change the root password.

Steps:

1.First open terminal.
2.if you are not login with root then login as a root.
Note:- take backup of your grub.conf file becuase if something goes wrong then you can recove it.
[root@linuxdude ~]# cp /boot/grub/grub.conf /boot/grub/old.grub.conf
[root@linuxdude ~]# grub-md5-crypt
password:******
Retype password:******
$1$bDAVbCOBwY67c3liHQq5GCU0
It will print your password in md5 format.You have to just copy this md5 password and past into your grub.conf file.
[root@linuxdude ~]# vi /boot/grub/grub.conf
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,5)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.23.17-88.fc7)
password –md5 $1$bDAVbCOBwY67c3liHQq5GCU0
root (hd0,5)
kernel /vmlinuz-2.6.23.17-88.fc7 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.23.17-88.fc7.img
title Fedora (2.6.21-1.3194.fc7)
root (hd0,5)
kernel /vmlinuz-2.6.21-1.3194.fc7 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.21-1.3194.fc7.img
title Other
rootnoverify (hd0,4)
chainloader +1
:) You have successfully proctected your Grub.


To Make Single User Mode Password Protected, Copy that md5 encrypted password which was generated by grub-md5-crypt and paste it exact after splashimage line.
[root@linuxdude ~]# vi /boot/grub/grub.conf
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,5)/grub/splash.xpm.gz
password –md5 $1$bDAVbCOBwY67c3liHQq5GCU0
hiddenmenu
title Fedora (2.6.23.17-88.fc7)
password –md5 $1$bDAVbCOBwY67c3liHQq5GCU0
root (hd0,5)
kernel /vmlinuz-2.6.23.17-88.fc7 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.23.17-88.fc7.img
title Fedora (2.6.21-1.3194.fc7)
root (hd0,5)
kernel /vmlinuz-2.6.21-1.3194.fc7 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.21-1.3194.fc7.img
title Other
rootnoverify (hd0,4)
chainloader +1
:) You have successfully proctected your single user mode.


Enjoy Linux !!!

No comments:

Post a Comment