Skip to main content
KBY Technologies Logo

Rotate a FileVault Recovery Key After a Helpdesk Unlock: RotateFileVaultKey and fdesetup

A FileVault recovery key was read out or used. Rotate it with RotateFileVaultKey or fdesetup, then check escrow and validaterecovery on a lab Mac first.

KBY Technologies11 min readTier L115 min
Rotate a FileVault Recovery Key After a Helpdesk Unlock: RotateFileVaultKey and fdesetup

Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.

Rotate the personal recovery key on any Mac whose key has been read out to a helpdesk agent, typed into a ticket or used to unlock the disk. Send the RotateFileVaultKey MDM command with KeyType set to personal and a ReplyEncryptionCertificate, or run fdesetup changerecovery -personal on the Mac. Then confirm the new key reached your escrow and that fdesetup validaterecovery returns true.

The constraint is that the command needs a FileVault user’s password, and the old key is removed when the new one is created. The new key has to be captured before anyone closes the session, or the recovery path is gone.

Apple documents the recovery key as a sequence of 24 random numbers and letters. It can be used in recoveryOS, or at the login window by pressing Shift-Option-Return, in place of the user’s password to unlock FileVault. Anyone who holds the key can therefore unlock the volume at those prompts, which is why a key that has been spoken aloud should not stay valid.

Apple’s FileVault documentation does not say that using the key changes it, so plan as if it stays valid until you rotate it.

#How it usually goes after a lockout

A user forgets their password or a password sync breaks. They phone the helpdesk, an agent opens the MDM console, finds the escrowed personal recovery key for that serial number and reads it out. The user unlocks the Mac, sets a new password and the ticket is closed with a note that the key was used.

Nothing in that flow rotates the key. As far as Apple documents, the same 24 characters stay valid, now known to the user, the agent, the call recording system if there is one and whatever the agent typed into the ticket. The only rotation most fleets have is a calendar reminder that nobody owns.

It also hides a second problem. If the key never reached your management service in the first place, the agent has nothing to read out and the lockout can end in a rebuild. The fix for a recovery key not escrowed to Jamf Pro deals with that case, and everything below assumes escrow works.

#What to do instead: make every retrieval create a rotation job

Treat the moment a key leaves escrow as an event. The retrieval, or a Mac reporting that it is unlocked with the key, opens a rotation job. The job rotates the key, escrows the new one and closes only when the new key validates. The agent who read the key out never needs to see the replacement.

Apple gives you two routes. Both produce a new personal recovery key, and they differ in who holds the secrets:

  • MDM command. The RotateFileVaultKey command runs on the device channel and needs the DeviceLockAndRemovePasscode access right. It is not available on user-enrolled devices. The new key comes back encrypted to a certificate you supply, so it does not have to pass through the console in the clear.
  • Local fdesetup. fdesetup changerecovery -personal runs as root on the Mac and generates the new key there. It suits a lab and scripted remediation, but you have to carry the new key to escrow yourself.

The distinction is a design choice, not a documented ranking. The MDM route keeps the new key out of every terminal on the way to escrow, which is why a fleet should prefer it. The local route is the one you use first, on a lab Mac, because you can watch it work.

Loading diagram...

Split the roles. Helpdesk agents can retrieve a key. A separate group, or automation running as one service identity, holds the right to send the rotation command and owns the reply certificate. Security reviews the weekly list of retrievals that did not produce a rotation.

#Setting it up on a lab Mac

Use a spare Mac with FileVault on and a test account that you can lose. Nothing here should be tried first on a production Mac, because rotation removes the old key and you cannot restore it.

  1. Record the baseline. Run the read-only checks below and save the output. You are looking for a status line saying FileVault is on and true from haspersonalrecoverykey. Stop if FileVault is not fully enabled, because The fdesetup manual page says false can also mean an error or that FileVault is not yet fully enabled.
  2. Note what escrow holds. In your MDM console, record the date of the stored key for this serial number. Do not copy the key itself anywhere.
  3. Make the reply certificate. ReplyEncryptionCertificate is a DER-encoded certificate. The new key comes back inside a Cryptographic Message Syntax envelope encrypted to it, so only the holder of the matching private key can open the reply. Whether your management service creates this certificate for you is a vendor detail; check its documentation.
  4. Send the command to the lab Mac. Set KeyType to personal. Put a FileVault user’s password in the FileVaultUnlock dictionary under Password. Add the ReplyEncryptionCertificate. The device answers with a RotateResult dictionary whose EncryptedNewRecoveryKey is the new key in its envelope.
  5. Escrow the reply. Decrypt the envelope inside your key custodian’s system and store the new key against the serial number. Stop here if the envelope will not open. Do not move on to a second Mac.

Following along? Tap a step’s number to tick it off.

1sudo fdesetup status
2sudo fdesetup haspersonalrecoverykey
3sudo fdesetup usingrecoverykey
4sudo fdesetup list -extended

The local route does the same job without the console. Create a property list that holds Username and Password for a FileVault user, keep it root-owned and unreadable by others, and read it on standard input:

1sudo fdesetup changerecovery -personal -inputplist < /private/var/root/authinfo.plist

The fdesetup manual page lists this form and says it changes the existing recovery key and generates a new one. It does not say where the new key is shown, so find that out on the lab Mac before you rely on it.

Delete the property list the moment the command returns. The Password value in that file can be either the user’s password or, in some cases, the recovery key itself, and on APFS volumes running 10.14 or later the existing recovery key can authenticate a change.

Close-up of hands typing on a laptop with a USB device on a white background. Ideal for tech and cybersecurity themes.
Photo by cottonbro studio on Pexels

#Keeping it safe

The password in FileVaultUnlock is a credential with the power to unlock the disk. Treat it that way: it must belong to a user who is already enabled for FileVault, never goes into a ticket or chat message, and does not live in a script in plain text. The Secure Token and volume owner audit shows which users can unlock a given Mac, which is the list your automation can draw from.

Keep the new key off disk. The manual page warns against writing the output of -outputplist to a persistent location because it adds security risk, and asks you to remove such a file securely as soon as you can. The same logic applies to your own reply handling: decrypt in memory, write to escrow and discard.

Do not reach for an institutional recovery key as a way round this. Apple says its use is no longer recommended for institutional management of FileVault, that it cannot be used to reach recoveryOS and that it provides no functional value on a Mac with Apple silicon. The personal key is the supported route.

Roll out in widening rings: the lab Mac, then a handful of IT-owned Macs, then everyone. Each ring waits for the previous one to show a validated new key. That pacing is a recommendation, not a vendor requirement.

#Checking it worked

Success is three things you can observe: the Mac still reports a personal recovery key, the key in escrow is a new one, and the old key no longer unlocks anything.

  1. Run sudo fdesetup haspersonalrecoverykey. It should print true.
  2. Run sudo fdesetup validaterecovery. The manual page says it gets the existing personal recovery key and returns true if it appears valid. Expect true.
  3. Compare the escrow date in the console with the baseline you saved. It should be later, and the new key should differ from the old one.
  4. On the lab Mac only, restart to the login window and try the old key with Shift-Option-Return. It should be refused. Then try the new key and confirm it unlocks, and sign in with the user’s password afterwards.
1sudo fdesetup validaterecovery

Note what fdesetup usingrecoverykey reports: it returns true only while the Mac is unlocked using the recovery key. That makes it a useful trigger for a script that runs at the first login after a lockout, but it says nothing about a key that was read out and then not used.

#What goes wrong

  • The command returns exit status 11. The manual page lists 11 as an authentication error. The password supplied is wrong, or belongs to a user who is not enabled for FileVault. Check the user against fdesetup list and try again once.
  • Exit status 1 or 2. FileVault is off, or it appears to be on but busy. Wait for encryption work to finish and check fdesetup status before retrying.
  • The command is refused on a user-enrolled device. The device-management documentation forbids user enrolment for this command. Such a Mac needs a local route or a different process.
  • The new key cannot be read. The reply envelope is encrypted to the certificate you sent. If the private key is not where you think it is, the new key is unreadable, and the old key is already gone. Fix this on the lab Mac before any other.
  • Escrow shows the old key. The console and the Mac disagree. A helpdesk agent will read out a key that no longer works, at the worst moment. Treat a stale escrow record as a failed rotation job, not a cosmetic issue.
  • Two jobs race. A second rotation overwrites the first, and only one key can exist at a time because the manual page says only one recovery key of each type can exist. Queue jobs per serial number.
Detailed shot of a laptop keyboard highlighting black keys and a red background.
Photo by Bruno Saito on Pexels

#Backing out when the new key is lost

There is no way to restore the old key; the manual page says the old value is removed and replaced. The recovery is to rotate again, which needs only a valid FileVault user’s password. On APFS volumes running macOS 10.14 or later the current recovery key also works as the authentication, so a key you still hold is enough.

If a rotation job fails part-way, stop and check fdesetup haspersonalrecoverykey and fdesetup validaterecovery before you send another command. Never remove the personal recovery key to force a clean state. The manual page says it is not recommended to remove all recovery keys, because if the FileVault password is lost the data may be inaccessible.

Escrow is the other half of rollback. Keep the previous record until the new one has validated and then mark it superseded, not deleted, so an audit can show when each key was current.

#How to tell it worked

Measure the gap that the old process left open. These come from your own console and ticket data, so start by counting them, not by setting a target:

  • The number of key retrievals in a week, and how many of them have a later escrow date.
  • The time between a retrieval and the validated rotation. A sensible aim is hours, not days, but set it from your own baseline.
  • The share of Macs where validaterecovery returns true.
  • Rotation jobs that ended in exit status 11 or an unreadable reply, which point to credential or certificate trouble.

Review the list weekly. A retrieval with no rotation is the case to chase: a user who was told the key and whose Mac still accepts it.

Rotation and restarts are separate jobs. restarting FileVault Macs remotely is its own procedure, so test the two separately.

#Before you roll out key rotation

  • Escrow works today for every Mac in scope, and a helpdesk agent can retrieve a key.
  • The device is enrolled in a way that permits RotateFileVaultKey, and your service holds the access right it needs.
  • The reply certificate exists, its private key is held by the key custodian and a lab decryption has succeeded.
  • The FileVault user password your automation uses is stored in a secrets system, not a script.
  • The lab Mac passed all four checks, including the refused old key.
  • Rotation jobs are queued per serial number and the first ring is IT-owned Macs.
  • The weekly retrievals-without-rotation report has a named owner.
  • Your vendor’s documentation has been checked for how it escrows the rotated key, because Apple’s pages do not describe any one product.

About this page

Credited to

Dates

Published

Sources

This page lists no external sources.

Corrections

No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.

Found this useful? Follow KBY for more like it.

Reader Interaction

Comments

Add a thoughtful note on Rotate a FileVault Recovery Key After a Helpdesk Unlock: RotateFileVaultKey and fdesetup. Comments are checked for spam and held for moderation before appearing.

Loading comments...

More from KBY that goes with this article.

Discover more

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

Operate smarter, with fewer recurring tickets.

Receive new operational playbooks, incident-prevention guidance, automation scripts and recovery runbooks.