Sub topic 8
Bootloader, Process Hardening, and Warning Banners
Assume you have root or sudo access to a test Linux server, understand systemd, and can recover the machine through a console or snapshot. Bootloader changes can prevent a server from starting, and firewall or SSH changes can block remote administration.
Protecting the boot process
The bootloader starts the kernel before normal Linux access controls are active. Anyone with console access may try to edit kernel arguments, boot an alternate entry, or enter a recovery mode. Protect the bootloader with a GRUB password and restrict physical or virtual-console access through your infrastructure provider.
First create a password hash:
sudo grub2-mkpasswd-pbkdf2Store the generated hash in the distribution's GRUB custom configuration. On RHEL-like systems, add a superuser and password hash to /etc/grub.d/01_users, then regenerate the configuration using the command appropriate for your boot mode:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# UEFI systems may instead use the vendor's documented EFI configuration path.Keep a recovery console available and test a reboot during a maintenance window. A GRUB password does not encrypt the disk. Use full-disk encryption when protection against offline disk access is required.
Kernel arguments can also reduce process-information exposure and disable features your workload does not need. Change them with grubby, rather than editing generated GRUB files directly:
sudo grubby --update-kernel=ALL --args="audit=1"
sudo grubby --info=ALL | grep -E 'kernel=|args='The exact arguments depend on the benchmark, kernel, and workload. Do not copy arguments between distributions without testing them.
Hardening processes
Process hardening limits information leaks and unsafe privilege behavior. A sysctl parameter is a kernel setting that can be loaded persistently from configuration files.
# /etc/sysctl.d/60-process-hardening.conf
fs.suid_dumpable = 0
kernel.yama.ptrace_scope = 1
kernel.randomize_va_space = 2Load and verify the settings:
sudo sysctl --system
sysctl fs.suid_dumpable kernel.yama.ptrace_scope kernel.randomize_va_spaceThese settings can affect debuggers, crash analysis, and monitoring agents. Record an approved exception if an application requires core dumps or unrestricted tracing.
Warning banners
A warning banner informs users that access is restricted and may be monitored. Use wording approved by your organization. Do not disclose system details such as distribution versions or hostnames.
# /etc/issue
Authorized use only. Activity may be monitored and recorded.
# /etc/issue.net
Authorized use only. Activity may be monitored and recorded.Display the remote banner through SSH:
# /etc/ssh/sshd_config.d/60-banner.conf
Banner /etc/issue.netValidate before reloading SSH:
sudo sshd -t
sudo systemctl reload sshd| Area | Verify |
|---|---|
| Bootloader | Password protection and recovery access |
| Processes | Effective `sysctl` values and application compatibility |
| Banners | Local console and SSH display approved wording |
Exercise
Why should you validate SSH configuration before reloading the service?
Show answer
A syntax error can prevent SSH from accepting new connections, so sshd -t reduces the chance of losing remote access.