Thursday, 28 December 2017

Set grub password in rhel7 or CentOS

--> Anyone can get the root login by breaking the root password in rhel7 or CentOS type OS

--> So to stop anyone to break root password we have to secure it by grub password.

# cd /etc/grub.d/

# ls
00_header  01_users  20_linux_xen     30_os-prober  41_custom
00_tuned   10_linux  20_ppc_terminfo  40_custom     README

--> First you have to generate the hash for password by using this command

# grub2-mkpasswd-pbkdf2
 Enter password: ******
 Reenter password: ******
 PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.1231312121
 fdafagadgg646564365j3j53h524klnlblh242lfhikufhiulaiunmln24wfkkhj
 sflfafjkl3l42kljlhrwi5ojhjb245jlbjhlhlkhjlkjj24lkhlhhkknlnafkjlanlkai99





--> copy the generated hash of password like from grub.pbkdf2... upto last



--> Then you have to select the 40_custom file in which you have to enter the following entries in the last line.



 # vim 40_custom

set superusers='root'
password_pbkdf2 root   ---------------paste here the generated password---------



# cd /boot/grub2/

# ls

# grub2-mkconfig > grub.cfg


# reboot

----> Press 'e' key at boot menu (To Check)

No comments:

Post a Comment