Secure Boot is a security standard that ensures a computer boots using only software that is trusted by the Original Equipment Manufacturer (OEM) or the user. In Linux, this is achieved by verifying the digital signature of the bootloader and the kernel against a set of trusted keys stored in the UEFI firmware. To enable it, you must either use a distribution that supports the Microsoft Third-Party UEFI CA (like Ubuntu or Fedora) or manually enroll your own Machine Owner Keys (MOK) to sign custom kernels and drivers.

What You'll Need

  • A computer with UEFI firmware (modern PCs generally have this; older BIOS systems do not support Secure Boot).
  • A Linux distribution installed on the system.
  • Administrative (root/sudo) access to the operating system.
  • Physical access to the machine to interact with the UEFI/BIOS menu and the MOK management screen during reboot.
  • A backup of your important data, as modifying boot configurations carries a risk of rendering the system temporarily unbootable.

Step-by-Step

Depending on your distribution, you may already have a signed bootloader. The following steps cover the most common method for managing Secure Boot on Linux using the Machine Owner Key (MOK) utility, which allows you to trust your own signatures without disabling Secure Boot entirely. Note that menu labels may differ slightly by motherboard manufacturer or firmware version.

  1. Check Current Secure Boot Status: Open a terminal and run bootctl status or mokutil --sb-state. If the output says "Secure Boot enabled," your system is already protected. If it says "disabled," you can proceed with the setup.
  2. Install Necessary Tools: Ensure you have the MOK utility installed. On Debian or Ubuntu-based systems, run sudo apt install mokutil openssl. On Fedora or RHEL, use sudo dnf install mokutil openssl.
  3. Generate Your Own Signing Keys: To sign your own kernel modules (like NVIDIA drivers or VirtualBox), you need a private key and a public certificate. Create a directory to store these keys securely: mkdir ~/mok-keys && cd ~/mok-keys. Then, generate the key pair using OpenSSL: openssl req -new -x509 -newkey rsa:2048 -keyout MOK.key -out MOK.crt -nodes -days 3650 -subj "/CN=My Linux Key/".
  4. Import the Public Key to the System: You must tell the UEFI firmware to trust your new certificate. Run the command sudo mokutil --import MOK.crt. The system will ask you to create a temporary password. Choose something simple, as you will only use it once during the next reboot.
  5. Reboot and Enroll the Key: Restart your computer. Before the OS loads, the system will enter a blue or grey screen called the "Shim UEFI Key Management" or "MOK Management" menu. Select Enroll MOK, then Continue, then Yes to enroll the key. Enter the temporary password you created in the previous step.
  6. Confirm Enrollment: Once the key is enrolled, select Reboot. The system will now boot back into Linux, and your custom keys are trusted by the firmware.
  7. Sign the Kernel or Modules: If you have unsigned modules (like proprietary drivers), you must sign them using the private key. Use the sbsign tool or the kernel's sign-file utility. For example: sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.key ./MOK.crt /lib/modules/$(uname -r)/updates/dkms/driver_name.ko.
  8. Enable Secure Boot in UEFI: Restart the computer and enter the UEFI/BIOS settings (usually by pressing F2, F12, or Del during startup). Navigate to the Security or Boot tab and change Secure Boot from "Disabled" to "Enabled". Save changes and exit.

Common Mistakes

One of the most frequent errors is forgetting to interact with the MOK menu during reboot. The MOK enrollment screen only appears for a few seconds; if you miss it, the key will not be imported, and the system will refuse to boot signed modules. Another common mistake is losing the MOK.key file. While the system only needs the .crt (certificate) to verify boots, you need the private key to sign any new kernel updates or driver installations. If you lose the key, you will have to generate a new one and repeat the enrollment process.

Users also frequently confuse "Secure Boot" with "Trusted Boot" or "Verified Boot." While related, Secure Boot specifically refers to the UEFI signature check. Some users attempt to enable Secure Boot before enrolling their keys, which can lead to a "Security Violation" error on startup, preventing the OS from loading entirely.

Tips

To make the process easier, keep a backup of your MOK.key and MOK.crt on a secure, encrypted USB drive. This ensures that if you reinstall your OS, you can re-import the same key without having to re-sign every single module manually. If you are using a distribution like Fedora or Ubuntu, try to use the official repositories for drivers, as these are often pre-signed by the distribution's own keys, removing the need for manual MOK management.

For those who want absolute control, consider putting your UEFI into "User Mode" or "Setup Mode." This allows you to delete the default Microsoft keys entirely and replace them with your own Platform Key (PK) and Key Exchange Keys (KEK). This is an advanced move that removes reliance on third-party vendors but requires a deep understanding of UEFI variables to avoid locking yourself out of the hardware.

Troubleshooting

If your system fails to boot after enabling Secure Boot and displays a "Security Violation" or "Invalid Signature" message, do not panic. This simply means the firmware did not find a trusted signature for the bootloader. The first and simplest fix is to reboot into your UEFI settings and temporarily disable Secure Boot. This will allow you to boot back into Linux, where you can check if your keys were properly enrolled using mokutil --list-enrolled.

If the MOK menu does not appear during reboot, you may need to trigger it manually. You can do this by running sudo mokutil --import MOK.crt again and ensuring you are not using a "Fast Boot" setting in your BIOS, as Fast Boot often skips the initialization steps required to display the MOK management screen. Disable "Fast Boot" or "Ultra Fast Boot" in the UEFI settings to ensure the Shim bootloader can interrupt the process.

If you encounter an error stating that the kernel is "Tainted" despite Secure Boot being on, check if you are loading any unsigned third-party modules. Secure Boot does not prevent the system from booting if a module is unsigned; it prevents that specific module from loading. Use dmesg | grep -i secure to see which specific drivers were blocked by the signature check.

Frequently Asked Questions

Does Secure Boot slow down my Linux boot time?

No. The signature verification happens almost instantaneously during the hand-off from firmware to bootloader and bootloader to kernel. The performance impact is negligible.

Can I use Secure Boot with NVIDIA drivers?

Yes, but because NVIDIA drivers are proprietary and compiled locally via DKMS, they are not signed by the distribution. You must use the MOK process described above to sign the NVIDIA modules yourself.

Will enabling Secure Boot break my dual-boot with Windows?

Generally, no. Windows requires Secure Boot for certain features (like Windows 11), and most Linux distributions use a "Shim" bootloader signed by Microsoft, allowing both OSs to coexist under Secure Boot.

What happens if I delete my MOK keys?

The system will still boot as long as the bootloader is signed by a trusted authority (like Microsoft or the Distro). However, any custom-signed drivers or kernels will stop loading until you generate and enroll new keys.

Is Secure Boot necessary for a home user?

While not strictly necessary, it provides a critical layer of defense against bootkits and rootkits that attempt to infect the system before the operating system even loads.