Step by Step: Shielding existing VMs without VMM

Published Mar 15 2019 04:09 PM 1,584 Views
Microsoft
First published on TECHNET on Sep 01, 2016
Continuing on the topic of Shielded VMs from my last blog on creating shielded VMs, this blogpost will share my learnings from validating the scenario. This blogpost doesn't dive deep in terminologies which are fully explained in the Shielded VM deployment guide .

A side note, System Center VMM has built-in functionality to support shielding existing VMs to make the process simpler, and it is recommended to use SCVMM to manage shielded VMs in production.

Process outline



  • Tenant admin creates the shielding data file, which defines the VM shielding policy and includes the certificates which restricts the VMs to run on allowed guarded fabrics

  • Tenant admin creates a helper VHDX that is used to shield the VMs

  • Fabric admin takes the shielding data file and helper VHDX, and shield an existing VM on a guarded host


Create Shielding Data (PDK) File for shielding existing VMs


The shielding data specifies the shielding policy and key material that identifies which fabrics can run shielded VMs. The tenant administrator creates the shielding data using the Shielding Data File Wizard (which is part of the Remote Server Administration Tools – Shielded VM Tools), on a machine which is not part of the guarded fabric. When running this tool, ensure to select the option for shielding existing VMs:

You can also use the following cmdlet to create the shielding data file:
New-ShieldingDataFile -ShieldingDataFilePath <PDK file path> -Owner $owner -Guardian $guardian -Policy <Shielded or EncryptionSupported>
Where $owner and $guardian are explained in this blogpost .

Tip: In testing, make sure you don’t run this tool/cmdlet on a guarded host.



Create a Helper VHDX


As part of the shielding process for existing VMs, a “helper VM” is created that is responsible for preparing and encrypting the existing VM’s VHDX. To make the Helper VHDX, you will need to create a fully functional Gen 2 VM (HelperVM) running Windows Server 2016 with either the desktop experience or Server Core installation option (Nano server is not supported for helper VHDXs). Make sure a user can log on to this VM before shutting it down. Once the VM is in the OFF state, make a copy of its VHDX file. This copy of VHDX file is referred to as a Helper VHDX. You can delete HelperVM and its configuration files if you want – they are not needed anymore.

Tips:




  • The Helper VHDX and VM to be shielded can’t come from the same VHDX file. This happens often in test labs, where the same VHDX files is copied multiple times to build HelperVM and other testing VMs. If the Helper VHDX and the VM to be shielded are originated from the same VHDX file, there will be disk signature conflicts which result in failure in the shielding process.

  • Do not use a differencing VHDX for the helper VHDX.


Run the following cmdlet to enable shielding feature in the Helper VHDX:
Initialize-VMShieldingHelperVHD -Path <Helper.vhdx>

Tips:




  • The cmdlet is part of the RSAT-> Feature Administration Tools -> Shielded VM tools. Make sure the Helper VHDX is on a Hyper-V host which is not the guarded host.

  • The VHDX file will be modified in place. If you want to keep a copy of the original VHDX, make sure you make a copy of the VHDX before running the cmdlet.

  • After the Helper VHDX is initialized, do not attach it to any VM.

  • Each Helper VHDX can only be used once after it has been initialized. If you are planning to shield multiple existing VMs, make a copy of the initialized Helper VHDX first. The script in the next section will make a copy for you if you run it in its entirety.


Shield an existing VM


The VMs to be shielded (let’s call them TargetVMs) are running on guarded hosts. Before running the script below, make sure you first copy the PDK files and the initialized Helper VHDX file to the guarded host where the TargetVMs are running.

There are two steps to shield the VM:

  • Prepare VM: Using the Helper VHDX to configures the TargetVM and encrypt its disk.

  • Enable shielding: Shield the VM based on the policy defined in the Shielding Data File.


The script below will perform the shielding process described above. The script takes 3 parameters:

  • PDKFile: the path to the shielding data file created above.

  • HelperVHDX: the path to the Helper VHDX file created and initialized, and copied to the guarded host.

  • VMName: the name of the TargetVM


You can copy and save the script, and run it on the guarded host to shield the VM.

[snippet slug=shieldexistingvm line_numbers=false lang=bsh]

Tips:




  • The TargetVM must not use a differencing VHDX. The provisioning job will fail immediately if it determines the TargetVM is running with differencing VHDX.

  • If an error occurred, you can also enable the “ShieldedVM-ProvionsioningService” debug event log channel to get more details on the error.

  • After the TargetVM is been prepared, the HelperVHDX file will be deleted. This is because the HelperVHDX can no longer be used to shield another VM. Make sure you make a copy of the HelperVHDX if you want to shield another VM.


Conclusion


This blogpost illustrated the steps to shield an existing VM without System Center Virtual Machine Manager(VMM). If you are using VMM to manage the fabric and it is recommended to use VMM in production, you can follow the deployment guide to learn the procedure.

I hope the script helps to simplify the process. As always, we’d love to hear your feedback. You can reach us by email at ShieldedVMFeedback@microsoft.com or submit and vote on requests through the User Voice web site
www.000webhost.com
%3CLINGO-SUB%20id%3D%22lingo-sub-372226%22%20slang%3D%22en-US%22%3EStep%20by%20Step%3A%20Shielding%20existing%20VMs%20without%20VMM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-372226%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20TECHNET%20on%20Sep%2001%2C%202016%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20Continuing%20on%20the%20topic%20of%20Shielded%20VMs%20from%20my%20last%20%3CA%20href%3D%22https%3A%2F%2Fblogs.technet.microsoft.com%2Fdatacentersecurity%2F2016%2F06%2F06%2Fstep-by-step-creating-shielded-vms-without-vmm%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20blog%20%3C%2FA%3E%20on%20creating%20shielded%20VMs%2C%20this%20blogpost%20will%20share%20my%20learnings%20from%20validating%20the%20scenario.%20This%20blogpost%20doesn't%26nbsp%3Bdive%20deep%20in%20terminologies%26nbsp%3Bwhich%20are%20fully%20explained%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2FShielded-VMs-and-Guarded-98d2b045%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Shielded%20VM%20deployment%20guide%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20A%20side%20note%2C%20System%20Center%20VMM%20has%20built-in%26nbsp%3Bfunctionality%20to%20support%20shielding%20existing%20VMs%20to%20make%20the%20process%20simpler%2C%20and%20it%20is%20recommended%20to%20use%20SCVMM%20to%20manage%20shielded%20VMs%20in%20production.%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-1702021116%22%20id%3D%22toc-hId-1732317607%22%3EProcess%20outline%3C%2FH2%3E%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3ETenant%20admin%20creates%20the%20shielding%20data%20file%2C%20which%20defines%20the%20VM%26nbsp%3Bshielding%20policy%20and%20includes%20the%20certificates%20which%20restricts%20the%20VMs%20to%20run%20on%20allowed%20guarded%20fabrics%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3ETenant%20admin%20creates%20a%20helper%20VHDX%26nbsp%3Bthat%20is%20used%20to%20shield%20the%20VMs%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EFabric%20admin%20takes%20the%20shielding%20data%20file%20and%20helper%20VHDX%2C%20and%20shield%20an%20existing%20VM%20on%20a%20guarded%20host%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId--850135845%22%20id%3D%22toc-hId--819839354%22%3ECreate%20Shielding%20Data%20(PDK)%20File%20for%20shielding%20existing%20VMs%3C%2FH2%3E%3CBR%20%2F%3E%20The%20shielding%20data%20specifies%20the%20shielding%20policy%20and%20key%20material%20that%20identifies%20which%20fabrics%20can%20run%20shielded%20VMs.%20The%20tenant%20administrator%20creates%20the%20shielding%20data%20using%20the%20Shielding%20Data%20File%20Wizard%20(which%20is%20part%20of%20the%20Remote%20Server%20Administration%20Tools%20%E2%80%93%20Shielded%20VM%20Tools)%2C%20on%20a%20machine%20which%20is%20not%20part%20of%20the%20guarded%20fabric.%20When%20running%20this%20tool%2C%20ensure%20to%20select%20the%20option%20for%20shielding%20existing%20VMs%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20You%20can%20also%20use%20the%20following%20cmdlet%20to%20create%20the%20shielding%20data%20file%3A%20%3CBR%20%2F%3E%20New-ShieldingDataFile%20-ShieldingDataFilePath%20%3CPDK%20file%3D%22%22%20path%3D%22%22%3E%20-Owner%20%24owner%20-Guardian%20%24guardian%20-Policy%20%3CSHIELDED%20or%3D%22%22%20encryptionsupported%3D%22%22%3E%20%3CBR%20%2F%3E%20Where%20%24owner%20and%20%24guardian%20are%20explained%20in%20this%20%3CA%20href%3D%22https%3A%2F%2Fblogs.technet.microsoft.com%2Fdatacentersecurity%2F2016%2F06%2F06%2Fstep-by-step-creating-shielded-vms-without-vmm%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20blogpost%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%3CP%3E%3CI%3E%20Tip%3A%20In%20testing%2C%20make%20sure%20you%20don%E2%80%99t%20run%20this%20tool%2Fcmdlet%20on%20a%20guarded%20host.%20%3C%2FI%3E%3C%2FP%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-892674490%22%20id%3D%22toc-hId-922970981%22%3ECreate%20a%20Helper%20VHDX%3C%2FH2%3E%3CBR%20%2F%3E%20As%20part%20of%20the%20shielding%20process%20for%20existing%20VMs%2C%20a%20%E2%80%9Chelper%20VM%E2%80%9D%20is%20created%20that%20is%20responsible%20for%20preparing%20and%20encrypting%20the%20existing%20VM%E2%80%99s%20VHDX.%20To%20make%20the%20Helper%20VHDX%2C%20you%20will%20need%20to%20create%20a%20fully%20functional%20Gen%202%20VM%20(HelperVM)%20running%20Windows%20Server%202016%20with%20either%20the%20desktop%20experience%20or%20Server%20Core%20installation%20option%20(Nano%20server%20is%20not%20supported%20for%20helper%20VHDXs).%20Make%20sure%20a%20user%20can%20log%20on%20to%20this%20VM%20before%20shutting%20it%20down.%20Once%20the%20VM%20is%20in%20the%20OFF%20state%2C%20make%20a%20copy%20of%20its%20VHDX%20file.%20This%20copy%20of%20VHDX%20file%20is%20referred%20to%20as%20a%20Helper%20VHDX.%20You%20can%20delete%20HelperVM%20and%20its%20configuration%20files%20if%20you%20want%20%E2%80%93%20they%20are%20not%20needed%20anymore.%20%3CBR%20%2F%3E%3CP%3E%3CI%3E%20Tips%3A%20%3C%2FI%3E%3C%2FP%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3E%3CI%3E%20The%20Helper%20VHDX%20and%20VM%20to%20be%20shielded%20can%E2%80%99t%20come%20from%20the%20same%20VHDX%20file.%20This%26nbsp%3Bhappens%20often%26nbsp%3Bin%20test%20labs%2C%20where%20the%20same%20VHDX%20files%20is%20copied%20multiple%20times%20to%20build%20HelperVM%20and%20other%20testing%20VMs.%20If%20the%20Helper%20VHDX%20and%20the%20VM%20to%20be%26nbsp%3Bshielded%20are%20originated%20from%20the%20same%20VHDX%20file%2C%20there%20will%20be%20disk%20signature%20conflicts%20which%20result%20in%20failure%20in%20the%26nbsp%3Bshielding%20process.%20%3C%2FI%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CI%3E%20Do%20not%20use%20a%20differencing%20VHDX%20for%20the%20helper%20VHDX.%20%3C%2FI%3E%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%20Run%20the%20following%20cmdlet%20to%26nbsp%3Benable%20shielding%20feature%26nbsp%3Bin%26nbsp%3Bthe%20Helper%20VHDX%3A%20%3CBR%20%2F%3E%20Initialize-VMShieldingHelperVHD%20-Path%20%3CHELPER.VHDX%3E%20%3CBR%20%2F%3E%3CP%3E%3CI%3E%20Tips%3A%20%3C%2FI%3E%3C%2FP%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3E%3CI%3E%20The%20cmdlet%20is%20part%20of%20the%20RSAT-%26gt%3B%20Feature%20Administration%20Tools%20-%26gt%3B%20Shielded%20VM%20tools.%20Make%20sure%20the%20Helper%20VHDX%20is%20on%20a%20Hyper-V%20host%20which%20is%20not%20the%20guarded%20host.%20%3C%2FI%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CI%3E%20The%20VHDX%20file%20will%20be%20modified%20in%20place.%20If%20you%20want%20to%20keep%20a%20copy%20of%20the%20original%20VHDX%2C%20make%20sure%20you%20make%20a%20copy%20of%20the%26nbsp%3BVHDX%20before%20running%20the%20cmdlet.%20%3C%2FI%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CI%3E%20After%20the%20Helper%20VHDX%20is%20initialized%2C%20do%20not%20attach%20it%20to%20any%20VM.%20%3C%2FI%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CI%3E%20Each%20Helper%20VHDX%20can%20only%20be%20used%20once%20after%20it%20has%20been%20initialized.%20If%20you%20are%20planning%20to%20shield%20multiple%20existing%20VMs%2C%20make%20a%20copy%20of%20the%20initialized%20Helper%20VHDX%20first.%20The%20script%20in%20the%20next%20section%20will%20make%20a%20copy%20for%20you%20if%20you%20run%20it%20in%20its%20entirety.%20%3C%2FI%3E%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId--1659482471%22%20id%3D%22toc-hId--1629185980%22%3EShield%20an%20existing%20VM%3C%2FH2%3E%3CBR%20%2F%3E%20The%20VMs%20to%20be%20shielded%20(let%E2%80%99s%20call%20them%20TargetVMs)%20are%20running%20on%20guarded%20hosts.%20Before%20running%20the%20script%20below%2C%20make%20sure%20you%20first%20copy%20the%20PDK%20files%20and%20the%20initialized%20Helper%20VHDX%20file%20to%20the%20guarded%20host%20where%20the%20TargetVMs%20are%20running.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20There%20are%20two%20steps%20to%20shield%20the%20VM%3A%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3EPrepare%20VM%3A%20Using%20the%20Helper%20VHDX%20to%20configures%20the%20TargetVM%20and%26nbsp%3Bencrypt%20its%20disk.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EEnable%20shielding%3A%20Shield%20the%20VM%20based%20on%20the%20policy%20defined%20in%20the%20Shielding%20Data%20File.%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%20The%20script%20below%20will%20perform%20the%20shielding%20process%20described%20above.%20The%20script%20takes%203%20parameters%3A%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3EPDKFile%3A%20the%20path%20to%20the%20shielding%20data%20file%20created%20above.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EHelperVHDX%3A%20the%20path%20to%20the%20Helper%20VHDX%20file%20created%20and%20initialized%2C%20and%20copied%20to%20the%20guarded%20host.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EVMName%3A%20the%20name%20of%20the%20TargetVM%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%20You%20can%20copy%20and%20save%20the%20script%2C%20and%20run%20it%20on%20the%20guarded%20host%20to%20shield%20the%20VM.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%5Bsnippet%20slug%3Dshieldexistingvm%20line_numbers%3Dfalse%20lang%3Dbsh%5D%20%3CBR%20%2F%3E%3CP%3E%3CI%3E%20Tips%3A%20%3C%2FI%3E%3C%2FP%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3E%3CI%3E%20The%20TargetVM%20must%20not%20use%20a%20differencing%20VHDX.%20The%20provisioning%20job%20will%20fail%20immediately%20if%20it%20determines%20the%20TargetVM%20is%20running%20with%20differencing%20VHDX.%20%3C%2FI%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CI%3E%20If%20an%20error%20occurred%2C%20you%20can%20also%20enable%20the%20%E2%80%9CShieldedVM-ProvionsioningService%E2%80%9D%20debug%20event%20log%20channel%20to%20get%20more%20details%20on%20the%20error.%20%3C%2FI%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CI%3E%20After%20the%20TargetVM%20is%20been%20prepared%2C%20the%20HelperVHDX%20file%20will%20be%20deleted.%20This%20is%20because%20the%20HelperVHDX%20can%20no%20longer%20be%20used%20to%20shield%20another%20VM.%20Make%20sure%20you%20make%20a%20copy%20of%20the%20HelperVHDX%20if%20you%20want%20to%20shield%20another%20VM.%20%3C%2FI%3E%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-83327864%22%20id%3D%22toc-hId-113624355%22%3EConclusion%3C%2FH2%3E%3CBR%20%2F%3E%20This%20blogpost%20illustrated%20the%20steps%20to%20shield%20an%20existing%20VM%20without%20System%20Center%20Virtual%20Machine%20Manager(VMM).%20If%20you%20are%20using%20VMM%20to%20manage%20the%20fabric%20and%20it%20is%20recommended%20to%20use%20VMM%20in%20production%2C%20you%20can%20follow%20the%20%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2FShielded-VMs-and-Guarded-98d2b045%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20deployment%20guide%20%3C%2FA%3E%20to%20learn%20the%20procedure.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20I%20hope%20the%20script%20helps%20to%20simplify%20the%20process.%20As%20always%2C%20we%E2%80%99d%20love%20to%20hear%20your%20feedback.%20You%20can%20reach%20us%20by%20email%20at%20ShieldedVMFeedback%40microsoft.com%20or%20submit%20and%20vote%20on%20requests%20through%20the%20%3CA%20href%3D%22https%3A%2F%2Fwindowsserver.uservoice.com%2Fforums%2F295065-security-and-assurance%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20User%20Voice%20web%20site%3C%2FA%3E%3C%2FHELPER.VHDX%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-372226%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TECHNET%20on%20Sep%2001%2C%202016%20Continuing%20on%20the%20topic%20of%20Shielded%20VMs%20from%20my%20last%20blog%26nbsp%3Bon%20creating%20shielded%20VMs%2C%20this%20blogpost%20will%20share%20my%20learnings%20from%20validating%20the%20scenario.%3C%2FLINGO-TEASER%3E%3C%2FSHIELDED%3E%3C%2FPDK%3E%3C%2FLINGO-BODY%3E
Version history
Last update:
‎Mar 15 2019 04:09 PM
Updated by: