Skip to content

Commit a9ec150

Browse files
Merge pull request #234106 from divargas-msft/patch-3
[Doc-a-thon] Updating how-to-verify-encryption-status.md
2 parents 3d2ef7f + 60ff9a4 commit a9ec150

File tree

1 file changed

+44
-27
lines changed

1 file changed

+44
-27
lines changed

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

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: virtual-machines
66
ms.subservice: disks
77
ms.topic: how-to
88
ms.author: mamccrea
9-
ms.date: 03/11/2020
9+
ms.date: 04/11/2023
1010
ms.custom: seodec18, devx-track-azurecli, devx-track-azurepowershell
1111

1212
---
@@ -56,7 +56,7 @@ Another way to validate the encryption status is by looking at the **Disk settin
5656

5757
You can validate the *general* encryption status of an encrypted VM by using the following PowerShell commands:
5858

59-
```azurepowershell
59+
```azurepowershell-interactive
6060
$VMNAME="VMNAME"
6161
$RGNAME="RGNAME"
6262
Get-AzVmDiskEncryptionStatus -ResourceGroupName ${RGNAME} -VMName ${VMNAME}
@@ -68,7 +68,7 @@ You can capture the encryption settings from each disk by using the following Po
6868
### Single pass
6969
In a single pass, the encryption settings are stamped on each of the disks (OS and data). You can capture the encryption settings for an OS disk in a single pass as follows:
7070

71-
```powershell
71+
```azurepowershell-interactive
7272
$RGNAME = "RGNAME"
7373
$VMNAME = "VMNAME"
7474
@@ -92,7 +92,7 @@ If the disk doesn't have encryption settings stamped, the output will be empty:
9292

9393
Use the following commands to capture encryption settings for data disks:
9494

95-
```azurepowershell
95+
```azurepowershell-interactive
9696
$RGNAME = "RGNAME"
9797
$VMNAME = "VMNAME"
9898
@@ -118,7 +118,7 @@ In a dual pass, the encryption settings are stamped in the VM model and not on e
118118

119119
To verify that the encryption settings were stamped in a dual pass, use the following commands:
120120

121-
```azurepowershell
121+
```azurepowershell-interactive
122122
$RGNAME = "RGNAME"
123123
$VMNAME = "VMNAME"
124124
@@ -142,7 +142,8 @@ Write-Host "====================================================================
142142
Check the encryption settings for disks that aren't attached to a VM.
143143

144144
### Managed disks
145-
```powershell
145+
146+
```azurepowershell-interactive
146147
$Sourcedisk = Get-AzDisk -ResourceGroupName ${RGNAME} -DiskName ${TARGETDISKNAME}
147148
Write-Host "============================================================================================================================================================="
148149
Write-Host "Encryption Settings:"
@@ -154,21 +155,24 @@ Write-Host "Secret URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSett
154155
Write-Host "Key URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.KeyEncryptionKey.KeyUrl
155156
Write-Host "============================================================================================================================================================="
156157
```
158+
157159
## Azure CLI
158160

159161
You can validate the *general* encryption status of an encrypted VM by using the following Azure CLI commands:
160162

161-
```azurecli
163+
```azurecli-interactive
162164
VMNAME="VMNAME"
163165
RGNAME="RGNAME"
164166
az vm encryption show --name ${VMNAME} --resource-group ${RGNAME} --query "substatus"
165167
```
168+
166169
![General encryption status from the Azure CLI ](./media/disk-encryption/verify-encryption-linux/verify-gen-cli.png)
167170

168171
### Single pass
172+
169173
You can validate the encryption settings for each disk by using the following Azure CLI commands:
170174

171-
```azurecli
175+
```azurecli-interactive
172176
az vm encryption show -g ${RGNAME} -n ${VMNAME} --query "disks[*].[name, statuses[*].displayStatus]" -o table
173177
```
174178

@@ -181,7 +185,7 @@ Use the following commands to get detailed status and encryption settings.
181185

182186
OS disk:
183187

184-
```bash
188+
```azurecli-interactive
185189
RGNAME="RGNAME"
186190
VMNAME="VNAME"
187191
@@ -201,7 +205,7 @@ done
201205

202206
Data disks:
203207

204-
```azurecli
208+
```azurecli-interactive
205209
RGNAME="RGNAME"
206210
VMNAME="VMNAME"
207211
az vm encryption show --name ${VMNAME} --resource-group ${RGNAME} --query "substatus"
@@ -221,15 +225,15 @@ done
221225

222226
### Dual pass
223227

224-
```azurecli
228+
```azurecli-interactive
225229
az vm encryption show --name ${VMNAME} --resource-group ${RGNAME} -o table
226230
```
227231

228232
![General encryption settings for dual pass via the Azure CLI](./media/disk-encryption/verify-encryption-linux/verify-gen-dual-cli.png)
229233

230234
You can also check the encryption settings on the VM Model Storage profile of the OS disk:
231235

232-
```bash
236+
```azurecli-interactive
233237
disk=`az vm show -g ${RGNAME} -n ${VMNAME} --query storageProfile.osDisk.name -o tsv`
234238
for disk in $disk; do \
235239
echo "============================================================================================================================================================="; \
@@ -250,7 +254,7 @@ Check the encryption settings for disks that aren't attached to a VM.
250254

251255
### Managed disks
252256

253-
```bash
257+
```azurecli-interactive
254258
RGNAME="RGNAME"
255259
TARGETDISKNAME="DISKNAME"
256260
echo "============================================================================================================================================================="
@@ -261,6 +265,7 @@ echo -ne "Disk Encryption Key: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME}
261265
echo -ne "key Encryption Key: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettings[].keyEncryptionKey.keyUrl -o tsv; \
262266
echo "============================================================================================================================================================="
263267
```
268+
264269
### Unmanaged disks
265270

266271
Unmanaged disks are VHD files that are stored as page blobs in Azure storage accounts.
@@ -274,55 +279,66 @@ To get the details for a specific disk, you need to provide:
274279

275280
This command lists all the IDs for all your storage accounts:
276281

277-
```azurecli
282+
```azurecli-interactive
278283
az storage account list --query [].[id] -o tsv
279284
```
285+
280286
The storage account IDs are listed in the following form:
281287

282288
/subscriptions/\<subscription id>/resourceGroups/\<resource group name>/providers/Microsoft.Storage/storageAccounts/\<storage account name>
283289

284290
Select the appropriate ID and store it on a variable:
285-
```bash
291+
292+
```azurecli-interactive
286293
id="/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.Storage/storageAccounts/<storage account name>"
287294
```
288295

289296
This command gets the connection string for one particular storage account and stores it on a variable:
290297

291-
```bash
298+
```azurecli-interactive
292299
ConnectionString=$(az storage account show-connection-string --ids $id --query connectionString -o tsv)
293300
```
294301

295302
The following command lists all the containers under a storage account:
296-
```azurecli
303+
304+
```azurecli-interactive
297305
az storage container list --connection-string $ConnectionString --query [].[name] -o tsv
298306
```
307+
299308
The container used for disks is normally named "vhds."
300309

301-
Store the container name on a variable:
302-
```bash
310+
Store the container name on a variable:
311+
312+
```azurecli-interactive
303313
ContainerName="name of the container"
304314
```
305315

306316
Use this command to list all the blobs on a particular container:
307-
```azurecli
317+
318+
```azurecli-interactive
308319
az storage blob list -c ${ContainerName} --connection-string $ConnectionString --query [].[name] -o tsv
309320
```
321+
310322
Choose the disk that you want to query and store its name on a variable:
311-
```bash
323+
324+
```azurecli-interactive
312325
DiskName="diskname.vhd"
313326
```
327+
314328
Query the disk encryption settings:
315-
```azurecli
329+
330+
```azurecli-interactive
316331
az storage blob show -c ${ContainerName} --connection-string ${ConnectionString} -n ${DiskName} --query metadata.DiskEncryptionSettings
317332
```
318333

319334
## Operating system
335+
320336
Validate if the data disk partitions are encrypted (and the OS disk isn't).
321337

322338
When a partition or disk is encrypted, it's displayed as a **crypt** type. When it's not encrypted, it's displayed as a **part/disk** type.
323339

324340
```bash
325-
lsblk
341+
sudo lsblk
326342
```
327343

328344
![OS crypt layer for a partition](./media/disk-encryption/verify-encryption-linux/verify-os-crypt-layer.png)
@@ -332,24 +348,25 @@ You can get more details by using the following **lsblk** variant.
332348
You'll see a **crypt** type layer that is mounted by the extension. The following example shows logical volumes and normal disks having **crypto\_LUKS FSTYPE**.
333349

334350
```bash
335-
lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,RO,MOUNTPOINT
351+
sudo lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,RO,MOUNTPOINT
336352
```
353+
337354
![OS crypt layer for logical volumes and normal disks](./media/disk-encryption/verify-encryption-linux/verify-os-crypt-layer-2.png)
338355

339356
As an extra step, you can validate if the data disk has any keys loaded:
340357

341358
```bash
342-
cryptsetup luksDump /dev/VGNAME/LVNAME
359+
sudo cryptsetup luksDump /dev/VGNAME/LVNAME
343360
```
344361

345362
```bash
346-
cryptsetup luksDump /dev/sdd1
363+
sudo cryptsetup luksDump /dev/sdd1
347364
```
348365

349366
And you can check which **dm** devices are listed as **crypt**:
350367

351368
```bash
352-
dmsetup ls --target crypt
369+
sudo dmsetup ls --target crypt
353370
```
354371

355372
## Next steps

0 commit comments

Comments
 (0)