Skip to content

Commit 1f92dec

Browse files
authored
Update how-to-verify-encryption-status.md
Updated how to verify encryption status, improved wording, acrolinx score, added commands to check encryption status on managed and unmanaged unattached disks
1 parent bda4572 commit 1f92dec

File tree

1 file changed

+150
-51
lines changed

1 file changed

+150
-51
lines changed

articles/virtual-machines/linux/how-to-verify-encryption-status.md

Lines changed: 150 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.custom: seodec18
1515

1616
# How to verify encryption status for Linux
1717

18-
**This scenario is applicable to ADE dual-pass and single-pass extensions.**
18+
**This scenario applies for ADE dual-pass and single-pass extensions.**
1919
This Document scope is to validate the encryption status of a virtual machine using different methods.
2020

2121
### Environment
@@ -24,35 +24,54 @@ This Document scope is to validate the encryption status of a virtual machine us
2424

2525
### Procedure
2626

27-
1. A virtual machine has been encrypted using dual-pass or single-pass.
28-
2. Once the encryption process is triggered (in progress) or has been completed, we can validate the encryption status using different methods defined below
27+
A virtual machine has been encrypted using dual-pass or single-pass.
28+
29+
The encryption status can be validated during or after the encryption using different methods.
30+
31+
>[!NOTE]
32+
>We're using variables throughout the document, replace the values accordingly.
2933
3034
### Verification
3135

32-
The encryption status validation can be done from the Portal, PowerShell, AZ CLI and/or within the VM (OS side). Below the different validations methods:
36+
The verification can be done from the Portal, PowerShell, AZ CLI and, or from the VM OS side.
37+
38+
This verification can be done by checking the disks attached to a particular VM.
39+
40+
Or by querying the encryption settings on each individual disk whether the disk is attached or unattached.
3341

34-
## Using the Portal:
42+
Below the different validations methods:
3543

36-
- You can validate the encryption status of a virtual machine by taking a look at the extensions blade in the corresponding virtual machine from the Portal.
37-
Inside the **Extensions** blade, you will see the ADE extension listed. You can click it and take a look at the **status message** which will indicate the current encryption status:
44+
## Using the Portal
45+
46+
Validate the encryption status by checking the extensions section on the Azure portal.
47+
48+
Inside the **Extensions** section, you'll see the ADE extension listed.
49+
50+
Click it and take a look at the **status message**, it will indicate the current encryption status:
3851

3952
![Portal check number 1](./media/disk-encryption/verify-encryption-linux/portal-check-001.png)
4053

41-
In the list of extensions, you will also be able to see the corresponding ADE extension version. Version 0.x corresponds to ADE Dual-Pass and version 1.x corresponds to ADE Single-pass
42-
You can also get further details clicking on the extension and then on *View detailed status*, once that's done, you will be able to see a more detailed status of the encryption process in json format as shown in the image below:
54+
In the list of extensions, you'll see the corresponding ADE extension version. Version 0.x corresponds to ADE Dual-Pass and version 1.x corresponds to ADE Single-pass.
55+
56+
You can get further details clicking on the extension and then on *View detailed status*.
57+
58+
You'll see a more detailed status of the encryption process in json format:
4359

4460
![Portal check number 2](./media/disk-encryption/verify-encryption-linux/portal-check-002.png)
4561

4662
![Portal check number 3](./media/disk-encryption/verify-encryption-linux/portal-check-003.png)
4763

48-
- Another way of validating the encryption status is by taking a look at the **Disks** blade. Over there, you get to see if encryption is enabled on each disk attached to a particular VM.
64+
Another way of validating the encryption status is by taking a look at the **Disks** section.
4965

5066
![Portal check number 4](./media/disk-encryption/verify-encryption-linux/portal-check-004.png)
5167

5268
>[!NOTE]
53-
> As a warning, this status is not too accurate. This just means the disks have encryption settings stamped but not that they were actually encrypted at OS level. Unfortunately by the way the ADE extension design works today, the disks get stamped first and encrypted later. If the encryption process fails, the disks may end up stamped but not encrypted. To confirm if the disks are truly encrypted, you can double check the encryption of each disk at OS level, following instructions in one of the upcoming sections.
69+
> This status means the disks have encryption settings stamped but not that they were actually encrypted at OS level.
70+
> By design, the disks get stamped first and encrypted later.
71+
> If the encryption process fails, the disks may end up stamped but not encrypted.
72+
> To confirm if the disks are truly encrypted, you can double check the encryption of each disk at OS level.
5473
55-
## Using PowerShell:
74+
## Using PowerShell
5675

5776
You can validate the **general** encryption status of an encrypted VM using the following PowerShell commands:
5877

@@ -61,16 +80,12 @@ You can validate the **general** encryption status of an encrypted VM using the
6180
$RGNAME="RGNAME"
6281
Get-AzVmDiskEncryptionStatus -ResourceGroupName ${RGNAME} -VMName ${VMNAME}
6382
```
64-
65-
>[!NOTE]
66-
> Replace the "VMNAME" and "RGNAME" variables accordingly
67-
68-
![verify status PowerShell 1](./media/disk-encryption/verify-encryption-linux/verify-status-ps-01.png)
83+
![check PowerShell 1](./media/disk-encryption/verify-encryption-linux/verify-status-ps-01.png)
6984

7085
You can capture the encryption settings from each individual disk using the following PowerShell commands:
7186

72-
**Single-Pass:**
73-
In the case of single-pass the encryption settings are stamped in each of the disks (OS and Data).
87+
**Single-Pass**
88+
If single-pass the encryption settings are stamped in each of the disks (OS and Data).
7489
You can capture the OS disk encryption settings in single pass as follows:
7590

7691
``` powershell
@@ -89,16 +104,12 @@ $VM = Get-AzVM -Name ${VMNAME} -ResourceGroupName ${RGNAME}
89104
Write-Host "Key URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.KeyEncryptionKey.KeyUrl
90105
Write-Host "============================================================================================================================================================="
91106
```
92-
93107
![Verify OS Single pass 01](./media/disk-encryption/verify-encryption-linux/verify-os-single-ps-001.png)
94108

95-
In case the disk does not have encryption settings stamped, the output will be empty as shown below:
109+
If the disk doesn't have encryption settings stamped, the output will be empty as shown below:
96110

97111
![OS Encryption settings 2](./media/disk-encryption/verify-encryption-linux/os-encryption-settings-2.png)
98112

99-
>[!NOTE]
100-
> Replace the $VMNAME and $RGNAME variables accordingly
101-
102113
Capture Data disk(s) encryption settings:
103114

104115
```azurepowershell
@@ -120,16 +131,12 @@ $VM = Get-AzVM -Name ${VMNAME} -ResourceGroupName ${RGNAME}
120131
Write-Host "============================================================================================================================================================="
121132
}
122133
```
123-
124134
![Verify data single ps 001](./media/disk-encryption/verify-encryption-linux/verify-data-single-ps-001.png)
125135

126-
>[!NOTE]
127-
> Replace the "VMNAME" and "RGNAME" variables accordingly
136+
**Dual-Pass**
137+
In Dual Pass, the encryption settings are stamped in the VM model and not on each individual disk.
128138

129-
**Dual-Pass**:
130-
In the case of dual pass, the encryption settings are stamped in the VM model and not on in individual disk.
131-
132-
To verify the encryption settings were stamped in dual-pass you can use the following commands:
139+
To verify the encryption settings were stamped in dual-pass, you can use the following commands:
133140

134141
```azurepowershell
135142
$RGNAME = "RGNAME"
@@ -148,13 +155,26 @@ Write-Host "Secret URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSett
148155
Write-Host "Key URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.KeyEncryptionKey.KeyUrl
149156
Write-Host "============================================================================================================================================================="
150157
```
158+
![Verify dual pass PowerShell 1](./media/disk-encryption/verify-encryption-linux/verify-dual-ps-001.png)
151159

152-
>[!NOTE]
153-
> Replace the "VMNAME" and "RGNAME" variables accordingly
160+
**Unattached disks**
154161

155-
![Verify dual pass PowerShell 1](./media/disk-encryption/verify-encryption-linux/verify-dual-ps-001.png)
162+
Check the encryption settings for disks that aren't attached to a VM.
156163

157-
## Using AZ CLI:
164+
**Managed disks**
165+
```powershell
166+
$Sourcedisk = Get-AzDisk -ResourceGroupName ${RGNAME} -DiskName ${TARGETDISKNAME}
167+
Write-Host "============================================================================================================================================================="
168+
Write-Host "Encryption Settings:"
169+
Write-Host "============================================================================================================================================================="
170+
Write-Host "Enabled:" $Sourcedisk.EncryptionSettingsCollection.Enabled
171+
Write-Host "Version:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettingsVersion
172+
Write-Host "Source Vault:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.DiskEncryptionKey.SourceVault.Id
173+
Write-Host "Secret URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.DiskEncryptionKey.SecretUrl
174+
Write-Host "Key URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.KeyEncryptionKey.KeyUrl
175+
Write-Host "============================================================================================================================================================="
176+
```
177+
## Using AZ CLI
158178

159179
You can validate the **general** encryption status of an encrypted VM using the following AZ CLI commands:
160180

@@ -163,22 +183,15 @@ VMNAME="VMNAME"
163183
RGNAME="RGNAME"
164184
az vm encryption show --name ${VMNAME} --resource-group ${RGNAME} --query "substatus"
165185
```
166-
167-
>[!NOTE]
168-
> Replace the "VMNAME" and "RGNAME" variables accordingly
169-
170186
![Verify general using CLI ](./media/disk-encryption/verify-encryption-linux/verify-gen-cli.png)
171187

172-
Single Pass:
188+
**Single Pass**
173189
You can validate the encryption settings from each individual disk using the following AZ CLI commands:
174190

175191
```bash
176192
az vm encryption show -g ${RGNAME} -n ${VMNAME} --query "disks[*].[name, statuses[*].displayStatus]" -o table
177193
```
178194

179-
>[!NOTE]
180-
> Replace the $VMNAME and $RGNAME variables accordingly
181-
182195
![Data encryption settings](./media/disk-encryption/verify-encryption-linux/data-encryption-settings-2.png)
183196

184197
>[!IMPORTANT]
@@ -198,6 +211,7 @@ for disk in $disk; do \
198211
echo "============================================================================================================================================================="
199212
echo -ne "Disk Name: "; az disk show -g ${RGNAME} -n ${disk} --query name -o tsv; \
200213
echo -ne "Encryption Enabled: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.enabled -o tsv; \
214+
echo -ne "Version: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettingsVersion -o tsv; \
201215
echo -ne "Disk Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].diskEncryptionKey.secretUrl -o tsv; \
202216
echo -ne "key Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].keyEncryptionKey.keyUrl -o tsv; \
203217
echo "============================================================================================================================================================="
@@ -214,9 +228,10 @@ VMNAME="VMNAME"
214228
az vm encryption show --name ${VMNAME} --resource-group ${RGNAME} --query "substatus"
215229

216230
for disk in `az vm show -g ${RGNAME} -n ${VMNAME} --query storageProfile.dataDisks[].name -o tsv`; do \
217-
echo "============================================================================================================================================================="
231+
echo "============================================================================================================================================================="; \
218232
echo -ne "Disk Name: "; az disk show -g ${RGNAME} -n ${disk} --query name -o tsv; \
219233
echo -ne "Encryption Enabled: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.enabled -o tsv; \
234+
echo -ne "Version: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettingsVersion -o tsv; \
220235
echo -ne "Disk Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].diskEncryptionKey.secretUrl -o tsv; \
221236
echo -ne "key Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].keyEncryptionKey.keyUrl -o tsv; \
222237
echo "============================================================================================================================================================="
@@ -225,7 +240,7 @@ done
225240

226241
![Data single CLI ](./media/disk-encryption/verify-encryption-linux/data-single-cli.png)
227242

228-
Dual Pass:
243+
**Dual Pass**
229244

230245
``` bash
231246
az vm encryption show --name ${VMNAME} --resource-group ${RGNAME} -o table
@@ -237,9 +252,10 @@ You can also check the Encryption settings on the VM Model Storage profile of th
237252
```bash
238253
disk=`az vm show -g ${RGNAME} -n ${VMNAME} --query storageProfile.osDisk.name -o tsv`
239254
for disk in $disk; do \
240-
echo "============================================================================================================================================================="
255+
echo "============================================================================================================================================================="; \
241256
echo -ne "Disk Name: "; az disk show -g ${RGNAME} -n ${disk} --query name -o tsv; \
242257
echo -ne "Encryption Enabled: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.enabled -o tsv; \
258+
echo -ne "Version: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettingsVersion -o tsv; \
243259
echo -ne "Disk Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].diskEncryptionKey.secretUrl -o tsv; \
244260
echo -ne "key Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].keyEncryptionKey.keyUrl -o tsv; \
245261
echo "============================================================================================================================================================="
@@ -248,23 +264,106 @@ done
248264

249265
![Verify vm profile dual using CLI ](./media/disk-encryption/verify-encryption-linux/verify-vm-profile-dual-cli.png)
250266

251-
## From the Linux VM OS:
252-
Validate if the data disk partitions are encrypted (and the OS disk is not). When a partition/disk is encrypted it's displayed as **crypt** type, when it's not encrypted it is displayed as **part/disk** type
267+
**Unattached disks**
268+
269+
Check the encryption settings for disks that aren't attached to a VM:
270+
271+
**Managed disks**
272+
273+
```bash
274+
RGNAME="RGNAME"
275+
TARGETDISKNAME="DISKNAME"
276+
echo "============================================================================================================================================================="
277+
echo -ne "Disk Name: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query name -o tsv; \
278+
echo -ne "Encryption Enabled: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.enabled -o tsv; \
279+
echo -ne "Version: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettingsVersion -o tsv; \
280+
echo -ne "Disk Encryption Key: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettings[].diskEncryptionKey.secretUrl -o tsv; \
281+
echo -ne "key Encryption Key: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettings[].keyEncryptionKey.keyUrl -o tsv; \
282+
echo "============================================================================================================================================================="
283+
```
284+
**Unmanaged disks**
285+
286+
Unmanaged disks are VHD files that are stored as page blobs in Azure storage accounts.
287+
288+
To get the details of a specific disk, you need to provide:
289+
290+
The ID of the storage account that contains the disk.
291+
A connection string for that particular storage account.
292+
The name of the container that stores the disk.
293+
The disk name.
294+
295+
This command lists all the IDs for all your storage accounts:
296+
297+
```bash
298+
az storage account list --query [].[id] -o tsv
299+
```
300+
The storage account IDs are listed in the following form:
301+
302+
/subscriptions/\<subscription id>/resourceGroups/\<resource group name>/providers/Microsoft.Storage/storageAccounts/\<storage account name>
303+
304+
Select the appropriate ID and store it on a variable:
305+
```bash
306+
id="/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.Storage/storageAccounts/<storage account name>"
307+
```
308+
The connection string:
309+
310+
This command gets the connection string for one particular storage account and stores it on a variable:
311+
312+
```bash
313+
ConnectionString=$(az storage account show-connection-string --ids $id --query connectionString -o tsv)
314+
```
315+
316+
The container name:
317+
318+
The following command lists all the containers under a storage account:
319+
```bash
320+
az storage container list --connection-string $ConnectionString --query [].[name] -o tsv
321+
```
322+
The container used for disks is normally named "vhds"
323+
324+
Store the container name on a variable
325+
```bash
326+
ContainerName="name of the container"
327+
```
328+
329+
The disk name:
330+
331+
Use this command to list all the blobs on a particular container
332+
```bash
333+
az storage blob list -c ${ContainerName} --connection-string $ConnectionString --query [].[name] -o tsv
334+
```
335+
Choose the disk you want to query and store its name on a variable.
336+
```bash
337+
DiskName="diskname.vhd"
338+
```
339+
Query the disk encryption settings
340+
```bash
341+
az storage blob show -c ${ContainerName} --connection-string ${ConnectionString} -n ${DiskName} --query metadata.DiskEncryptionSettings
342+
```
343+
344+
## From the OS
345+
Validate if the data disk partitions are encrypted (and the OS disk isn't)
346+
347+
When a partition/disk is encrypted it's displayed as **crypt** type, when it's not encrypted it's displayed as **part/disk** type
253348

254349
``` bash
255350
lsblk
256351
```
257352

258353
![Os Crypt layer ](./media/disk-encryption/verify-encryption-linux/verify-os-crypt-layer.png)
259354

260-
You can get further details using the following "lsblk" variant. Using this one, you'll see a **crypt** type layer that is mounted by the extension, the following example shows Logical Volumes and normal disks having a **crypto\_LUKS FSTYPE**.
355+
You can get further details using the following "lsblk" variant.
356+
357+
You'll see a **crypt** type layer that is mounted by the extension.
358+
359+
The following example shows Logical Volumes and normal disks having a "**crypto\_LUKS FSTYPE**".
261360

262361
```bash
263362
lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,RO,MOUNTPOINT
264363
```
265364
![Os Crypt layer 2](./media/disk-encryption/verify-encryption-linux/verify-os-crypt-layer-2.png)
266365

267-
As an extra step, you can also validate if the data disk has any dmcrypt keys loaded
366+
As an extra step, you can also validate if the data disk has any keys loaded
268367

269368
``` bash
270369
cryptsetup luksDump /dev/VGNAME/LVNAME
@@ -282,4 +381,4 @@ dmsetup ls --target crypt
282381

283382
## Next Steps
284383

285-
- [Azure Disk Encryption troubleshooting](disk-encryption-troubleshooting.md)
384+
- [Azure Disk Encryption troubleshooting](disk-encryption-troubleshooting.md)

0 commit comments

Comments
 (0)