Skip to content
Menu

FileVault Is Off or Has No Recovery Key

Checks that FileVault disk encryption is on and that the Mac has a recovery key. It alerts when FileVault is off, is being turned off, or is on with no key. It never prints a key.

FileVault is off or has no recovery key is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review FileVault is off or has no recovery key. Tell other MSPs how it worked for you.

Write a Review

LanguageBash
Runs onmacOS 13+; runs as root
Needsbash 3.2, root, fdesetup
Read-onlyReads, changes nothing

What It Does

The script runs fdesetup to read whether FileVault is on, encrypting, decrypting, or only waiting for the next login, which is called deferred enablement. When FileVault is on and not decrypting, it checks for personal and institutional recovery keys, including while encryption is running. It alerts when FileVault is off, when it is being turned off, or when it is on and no recovery key of either kind exists. It never prints a key.

Encryption in progress passes the encryption check. If FileVault is on and required recovery keys are absent, encryption progress does not prevent an alert. If either key check cannot be read, the script reports an error. ALERT_WHEN_OFF=false suppresses only the off-state finding; decryption and deferred enablement still alert. REQUIRE_RECOVERY_KEY=false suppresses the missing-key alert.

A Mac cannot tell the script where a recovery key was sent. Personal key exists is all fdesetup can say, and whether your MDM holds a copy has to be checked in the MDM. A Mac with no FileVault at all is skipped. Run it as root, which an RMM does, because reading the recovery key state needs it.

Before You Run It

  • Run it as root. Reading the recovery key state needs it.
  • Check your MDM for the escrowed key. This script reads only that a key exists on the Mac.
  • Set ALERT_WHEN_OFF to false for Macs where encryption is not your policy, such as a shared lab machine.
  • Alert on the exit code in your RMM. An exit of 1 means FileVault or the key needs attention.

Type and Risk

  • Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 5 seconds.
  • Example answer: "FileVault on; personal recovery key present; no institutional key"
  • Tested before listing on macOS 27 (Apple silicon VM) with /bin/bash 3.2, run as root, against its own test cases.

Inputs

Pass an input as an argument (--input-name value), as an environment variable named as listed, which is how most RMMs pass script variables, or change its default in the DEFAULT_ lines near the top of the script. An argument wins over an environment variable, which wins over the default.

  • ALERT_WHEN_OFF: Alert when FileVault is off. Default true.
  • REQUIRE_RECOVERY_KEY: Alert when FileVault is on but no recovery key exists. Default true.

Every script also takes DRY_RUN, OUTPUT_FORMAT (Text, Answer, Json or Csv), EXPORT_PATH and RESULT_FIELD, which writes the answer to an RMM custom field, unless the list above words one differently.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

test-filevault-status.sh · 589 lines · 26.2 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.