sections in this module City College of San Francisco - CS260A
Unix/Linux System Administration

Module: StartupShutdown III
module list

Protecting the Boot Process in RH7

Just like in RH6.5, restricting physical access to the machine is the most important protection mechanism to protect the startup sequence. Any knowledgeable user who has physical access to the machine can break in. This is just as easy in RH7 as it was in RH6.5.

Whenever systemd goes to single-user mode (whether it is emergency or rescue, as explained in the next section), the single-user shell is password protected. Assuming the intruder does not have a rescue disk he or she can use, password-protecting grub2, as explained in the next section, is a helpful deterrent.

For the duration of this discussion, grub refers to grub2 unless specifically indicated otherwise.

Protecting grub

Unless there is a separate configuration entry to invoke single-user mode, getting to it requires modifying grub's default configuration entry like this:

To disable editing boot configurations, add a password to grub

Setting a grub password

grub2 password authentication involves both a user and a password. You can set passwords on a per-configuration basis to control who can boot various configurations, but this involves modifying the scripts in /etc/grub.d. I will leave that to you if you want to go over it.

The ability to edit configurations is controlled by the grub 'superuser'. If one is defined, the superuser must login with an account and password to be able to modify configurations or access grub's command-line. This involves a simple append of the /etc/grub.d/40_custom file and rebuilding grub's configuration file:

the superuser is set by

set superusers="name"

where name is the name of the account (root is traditional, of course, but that is the first one anyone would guess). This can be a list of accounts, space-separated.

then a password is set for each user by

password name plaintextpassword

for a plain text password (in which case you must make sure grub.cfg and 40_custom are not readable by anyone else) or

password_pbkdf2 user encryptedpassword

where encryptedpassword is generated by the grub2-mkpasswd-pbkdf2 command:

# grub2-mkpasswd-pbkdf2
Enter password:
Reenter password:
PBKDF2 hash of your password is encryptedpassword

encryptedpassword will start with some plaintext stuff that indicates the type of password. Leave it on.

Note: the handy program grub-password, which we have used to generate shadow-style encrypted passwords, is not available on RH7. However, you can still generate encrypted passwords using python. This is discussed in the section on passwords in the Users and Authentication section.

Example of 40_custom showing a superuser with an encrypted password

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
set superusers="gboyd"
password_pbkdf2 gboyd grub.pbkdf2.sha512.10000.4C8B0CD061DD48619C390A2A3A2206F7A
215B13D9FDA0DD07ECCBB1871FC57064F65A8467420610C41F1906CC3F85CA50D9BC2F108F7AFF4D
4509BEB22055706.FB899664DED47AC2D951366C58115763572CFB0388AFDE00AC62C7CD72E53399
31F54332E499C66EC4A97B861DF892798D4CBDE4C8D34FF2B66F2DBE8E3BA6E1

the bold text is the standard part of the file. The unbolded part is added. Of course the password must be on a single line.

Then grub's config file is rebuilt using

grub2-mkconfig -o /boot/grub2/grub.cfg

Access to grub 

Just like with grub1, you must protect grub's configuration files and the scripts that grub2-mkconfig uses to rebuild the configuration files. No one but root should be allowed access to these directories (/boot/grub2 and /etc/grub.d)


Prev This page was made entirely with free software on linux:  
Kompozer, the Mozilla Project
and Openoffice.org      
Next

Copyright 2014 Greg Boyd - All Rights Reserved.