Protect grub with password

Protect grub with password

Question: How to protect grub with password

Answer: To protect grub with a password. We need to add password in file /boot/grub/grub.conf

 

Protect grub with password

 

In this post i am going to explain you about how to protect grub with complex password. In server security is one of the most important aspect. Even though if you have some high configuration of hardware’s the server can be hacked if it is not secured. As part of security aspect previously we have seen how to protect single user mode with root password and now we are going to learn how to protect grub with password.

OK! Let’s protect grub with password.

Give the below command to create encrypted password

#/sbin/grub-md5-crypt

It will ask you for password two times. In my scenario i have used Pr)^3C7@Gr($ as the password. Once it is done copy the encrypted content. Then open file /boot/grub/grub.conf using vi editor. Add this encrypted password below timeout variable.

#rpm -qvf /sbin/grub-md5-crypt
grub-0.97-13
#/sbin/grub-md5-crypt
Password:
Retype password:
$1$CQpZ41$O8Q2P9sSWSKAEyE22oE6H.

#vi /boot/grub/grub.conf

timeout=5
#Add this encrypted password below timeout variable.
password –md5 $1$CQpZ41$O8Q2P9sSWSKAEyE22oE6H.

 

Another Method

 

We can also add plain text password to protect grub instead of giving encrypted password. To do that open the file /boot/grub/grub.conf using vi editor. Add this plain text password below timeout variable.

#vi /boot/grub/grub.conf

timeout=5
#Add this encrypted password below timeout variable.
password=HardPassword@#@!

Both of the methods will work. To test whether it is working or not reboot the server and try to access the grub mode. Don’t forget the grub password.

Check our new blog about how to remove GRUB password.




Leave a Reply

Your email address will not be published. Required fields are marked *