Cleaning up the Mess Left Behind by Multiple EFS Certificates

In case you have (un?)wittingly been juggling around with multiple EFS certificates like me, you may feel a strong urge to clean up the mess. Which mess? It can happen quite easily that different files are encrypted with different keys. In addition to that, directories that are marked for encryption have EFS certificates associated with them, and there is no UI to manipulate that. In order to straighten this out, once the proper certificate is in place each file and directory needs to be “touched” in order to update their encryption keys.

Command Line to the Rescue

Here are a few simple commands that help with the process of getting back to only one certificate per machine and user. They rely on the command line tool cipher.exe that has been part of the OS since the days of Windows 2000.

Show the fingerprint of the currently used certificate:

cipher /y

Show encryption information for all files and folders in the current directory:

cipher /c /h

Re-key all folders, i.e. replace the certificate to be used for files created in each folder with the current certificate. Log to the file rekey_log.txt in the current folder.

for /f "usebackq delims=" %i in (`dir /ad /b /s`) do @cipher /rekey "%i" 1>>rekey_log.txt 2>>&1

Access all encrypted files on all local drives in order to update each file’s certificate with the current certificate. Log to the file cipher_u_log.txt in the current folder.

cipher /u 1>>cipher_u_log.txt 2>>&1

Comments

Related Posts

New Articles, Tools, Tips and Tricks: Bugs, Annoyances, PowerShell and some other Stuff

New Articles, Tools, Tips and Tricks: Bugs, Annoyances, PowerShell and some other Stuff
Bugs and Annoyances ICA connections initiated over the ICA client object (ICO) SDK fail because 128-bit encryption cannot be enabled. Apparently, setting EncryptionLevelSession does not work. Annoyingly, this bug is more than a year old, was fixed in the ICA client 10.2 and reappeared in the current version 11.0. Bugs like this one are bad for the entire Citrix ecosystem, because they break cool tools like Citrix Quick Launch, xConnect and others I may not even know about. [Update 2009-09-30: this bug has been fixed in ICA client 11.2.]
Tips and Tools

Latest Posts

Filebrowser to Be Archived. Migrate to a Modern Alternative: Sambee

Filebrowser to Be Archived. Migrate to a Modern Alternative: Sambee
Filebrowser is being archived. As the author writes, the codebase dates back to when he was but 15 years old. Having created such a popular file management tool is a more than impressive achievement for anyone, let alone a teenager. However, when it comes to security and reliability, Filebrowser seems to be built on a less than ideal foundation, so much so that the author states:
Home Automation, Networking & Self-Hosting