在 Azure Key Vault 中安全地儲存及管理 MARS 代理程式複雜密碼

使用復原服務代理程式 (MARS) 的 Azure 備份可讓您將檔案/資料夾和系統狀態資料備份至 Azure 復原服務保存庫。 此資料會使用您在 MARS 代理程式安裝和註冊期間所提供的複雜密碼進行加密。 需要此複雜密碼才能擷取和還原備份資料,而且必須儲存在安全的外部位置。

重要

如果遺失此複雜密碼,Microsoft 將無法擷取儲存在復原服務保存庫中的備份資料。 建議您將此複雜密碼儲存在安全的外部位置,例如 Azure Key Vault。

現在,在新機器的安裝期間,您可以從 MARS 主控台將加密複雜密碼安全地儲存在 Azure Key Vault 中作為秘密,而針對現有機器則可以透過變更複雜密碼來修改儲存位置。 若要允許將複雜密碼儲存至 Azure Key Vault,您必須將權限授與復原服務保存庫,才能在 Azure Key Vault 中建立秘密。

在您開始使用 Intune 之前

設定復原服務保存庫以將複雜密碼儲存至 Azure Key Vault

在將複雜密碼儲存至 Azure Key Vault 之前,請先設定復原服務保存庫和 Azure Key Vault。

若要設定保存庫,請依照指定順序執行下列步驟,以達成預期的結果。 下列各節會詳細討論每個動作:

  1. 為復原服務保存庫啟用系統指派的受控識別。
  2. 將權限指派給復原服務保存庫,以將複雜密碼儲存為 Azure Key Vault 中的秘密。
  3. 在 Azure Key Vault 上啟用虛刪除和清除保護。

注意

  • 啟用此功能之後,您便無法停用受控識別 (即使是暫時)。 停用受控識別可能會導致不一致的行為。
  • 使用者指派的受控識別目前不支援在 Azure Key Vault 中儲存複雜密碼。

為復原服務保存庫啟用系統指派的受控識別

選擇用戶端

執行下列步驟:

  1. 移至 [復原服務保存庫]>[身分識別]

    Screenshot shows how to go to Identity in Recovery Services vault.

  2. 選取 [系統指派] 索引標籤。

  3. 將 [狀態] 變更為 [開啟]

  4. 選取 [儲存],以啟用保存庫的身分識別。

隨即產生物件識別碼,也就是系統指派的保存庫受控識別。

指派權限以在 Azure Key Vault 中儲存複雜密碼

根據針對 Key Vault 設定的權限模型 (角色型存取權限或存取原則型),請參閱下列各節。

使用角色型存取權限模型為 Key Vault 啟用權限

選擇用戶端:

若要指派權限,請遵循下列步驟:

  1. 移至您的 [Azure Key Vault]>[設定]>[存取設定] 以確保權限模型為 [RBAC]

    Screenshot shows how to open access configuration under settings.

  2. 選取 [存取控制 (IAM)]>[+新增] 以新增角色指派。

  3. 復原服務保存庫身分識別需要秘密上的「設定」權限,才能建立複雜密碼,並新增為 Key Vault 的秘密。

    您可以選取「內建角色」,例如具有權限的 Key Vault 秘密長 (包含此功能不需要的其他權限),或建立僅具有秘密上的「設定」權限的自訂角色

    在 [詳細資料] 底下,選取[檢視] 以檢視角色授與的權限,並確定「秘密」上的 [設定] 權限可供使用。

    Screenshot shows how to view the permission details.

    Screenshot shows how to check the Set permission availability.

  4. 選取 [下一步] 以繼續選取要指派的成員。

  5. 選取 [受控識別],然後選取 [+ 選取成員]。 選擇目標復原服務保存庫的 [訂用帳戶],選取 [系統指派的受控識別] 下的 [復原服務保存庫]。

    搜尋並選取「復原服務保存庫的名稱」

    Screenshot shows how to add members in managed identity.

  6. 選取 [下一步]、檢閱指派,然後選取 [檢閱 + 指派]

    Screenshot shows how to review and assign permissions.

  7. 移至 Key Vault 中的 [存取控制 (IAM)],選取 [角色指派],並確定已列出復原服務保存庫。

    Screenshot shows the Recovery Services vault is listed in access control.

使用存取原則權限模型為 Key Vault 啟用權限

選擇用戶端

執行下列步驟:

  1. 移至您的 [Azure Key Vault]>[存取原則]>[存取原則],然後選取 [+ 建立]

    Screenshot shows how to start creating a Key Vault.

  2. 在 [秘密權限] 底下,選取 [設定作業]

    這會指定秘密上允許的動作。

    Screenshot shows how to start setting permissions.

  3. 移至 [選取主體],並使用其名稱或受控識別,在搜尋方塊中搜尋您的「保存庫」

    從搜尋結果中選取「保存庫」,然後選擇 [選取]

    Screenshot shows the assignment of permission to a selected vault.

  4. 移至 [檢閱 + 建立],確定 [設定權限] 可供使用,且 [主體] 是正確的「復原服務保存庫」,然後選取 [建立]

    Screenshot shows the verification of the assigned Recovery Services vault and create the Key Vault.

    Screenshot shows how to verify the access present.

在 Azure Key Vault 上啟用虛刪除和清除保護

您必須在儲存加密金鑰的 Azure Key Vault 上啟用虛刪除和清除保護。

選擇用戶端*

您可以從 Azure Key Vault 啟用虛刪除和清除保護。

或者,您可以在建立 Key Vault 時,設定這些屬性。 深入了解這些 Key Vault 屬性。

Screenshot shows how to enable spft-delete.

針對新的 MARS 安裝將複雜密碼儲存至 Azure Key Vault

在繼續安裝 MARS 代理程式之前,請確定您已設定復原服務保存庫以將複雜密碼儲存至 Azure Key Vault,且已成功完成下列事項:

  1. 建立您的復原服務保存庫。

  2. 已為復原服務保存庫啟用系統指派的受控識別。

  3. 將權限指派給復原服務保存庫,以在 Key Vault 中建立秘密。

  4. 為 Key Vault 啟用虛刪除和清除保護。

  5. 若要在電腦上安裝 MARS 代理程式,請從 Azure 入口網站下載 MARS 安裝程式,然後使用安裝精靈

  6. 在註冊期間提供復原服務保存庫認證之後,請在 [加密設定] 中選取選項,將複雜密碼儲存至 Azure Key Vault。

    Screenshot shows the option to save the passphrase to Azure Key Vault to be selected.

  7. 輸入您的複雜密碼,或選取 [產生複雜密碼]

  8. Azure 入口網站中,開啟您的 Key Vault,複製「Key Vault URI」

    Screenshot shows how to copy the Key Vault URI.

  9. 在 MARS 主控台貼上 Key Vault URI,然後選取 [註冊]

    如果您遇到錯誤,請查看疑難排解一節以取得詳細資訊。

  10. 註冊成功之後,隨即會建立「將識別碼複製到秘密」的選項,且複雜密碼「不會」儲存到本機的檔案。

    Screenshot shows the option to copy the identifier to the Secret gets creates.

    如果您在未來變更此 MARS 代理程式的複雜密碼,系統將使用最新的複雜密碼來新增秘密的新版本。

您可以在安裝指令碼Set-OBMachineSetting command 中使用新的 KeyVaultUri 選項,將此程序自動化。

針對現有的 MARS 安裝將複雜密碼儲存至 Azure Key Vault

如果您已有 MARS 代理程式安裝,且想要將複雜密碼儲存至 Azure Key Vault,請將代理程式更新2.0.9262.0 或更新版本,並執行變更複雜密碼作業。

在更新 MARS 代理程式之後,請確定您已將復原服務保存庫設定為將複雜密碼儲存至 Azure Key Vault,且已成功完成下列事項:

  1. 建立您的復原服務保存庫。
  2. 已為復原服務保存庫啟用系統指派的受控識別。
  3. 將權限指派給復原服務保存庫,以在 Key Vault 中建立秘密。
  4. 為 Key Vault 啟用虛刪除和清除保護

若要將複雜密碼儲存至 Key Vault:

  1. 開啟 MARS 代理程式主控台

    系統應該會顯示橫幅,要求您選取連結以將複雜密碼儲存至 Azure Key Vault。

    或者,選取 [變更屬性]>[變更複雜密碼] 以繼續進行。

    Screenshot shows how to start changing passphrase for an existing MARS installation.

  2. 在 [變更屬性] 對話方塊中,將出現「提供 Key Vault URI 以將複雜密碼儲存至 Key Vault」的選項

    注意

    如果機器已設定為將複雜密碼儲存至 Key Vault,系統會自動在文字方塊中填入 Key Vault URI。

    Screenshot shows the option to save passphrase to Key Vault by providing a Key Vault URI gets generated.

  3. 開啟 Azure 入口網站、開啟您的 Key Vault,然後複製 Key Vault URI

    Screenshot shows how to copy the Key Vault URI.

  4. 在 MARS 主控台中貼上 Key Vault URI,然後選取 [確定]

    如果您遇到錯誤,請查看疑難排解一節以取得詳細資訊。

  5. 變更複雜密碼作業成功後,隨即會建立「將識別碼複製到秘密」的選項,而且複雜密碼「不會」儲存到本機的檔案。

    Screenshot shows an option to copy the identifier to the Secret gets created.

    如果您在未來變更此 MARS 代理程式的複雜密碼,系統將使用最新的複雜密碼來新增秘密的新版本

您可以在 Set-OBMachineSetting Cmdlet 中使用新的 KeyVaultUri 選項,將此步驟自動化。

從 Azure Key Vault 擷取機器的複雜密碼

如果您的機器變得無法使用,且需要透過替代位置還原從復原服務保存庫還原備份資料,則需要機器的複雜密碼才能繼續。

複雜密碼會儲存至 Azure Key Vault 作為秘密。 每部機器會建立一個秘密,而且當機器的複雜密碼變更時,新版本就會新增至秘密。 密碼名為 AzBackup-machine fully qualified name-vault name

若要找出機器的複雜密碼:

  1. Azure 入口網站中,開啟用來儲存機器複雜密碼的 Key Vault

    建議您將所有複雜密碼儲存在一個 Key Vault 中。

  2. 選取 [秘密],然後搜尋名為 AzBackup-<machine name>-<vaultname> 的秘密。

    Screenshot shows bow to check for the secret name.

  3. 選取 [秘密]、開啟最新版本,並複製秘密的值

    這是復原期間要使用的機器複雜密碼。

    Screenshot shows selection of the secret.

    如果您的 Key Vault 中有大量秘密,請使用 Key Vault CLI 來列出和搜尋秘密。

az keyvault secret list --vault-name 'myvaultname’ | jq '.[] | select(.name|test("AzBackup-<myvmname>"))'

常見案例疑難排解

本節列出將複雜密碼儲存至 Azure Key Vault 時常見的錯誤。

未設定系統身分識別 – 391224

原因:如果復原服務保存庫未設定系統指派的受控識別,就會發生此錯誤。

建議的動作:請確定已根據必要條件為復原服務保存庫正確設定系統指派的受控識別。

未設定權限 – 391225

原因:復原服務保存庫具有系統指派的受控識別,但沒有在目標 Key Vault 中建立秘密的設定權限

建議動作:

  1. 請確定所使用的保存庫認證對應至預期的復原服務保存庫。
  2. 確定 Key Vault URI 對應至預期的 Key Vault。
  3. 確定復原服務保存庫名稱列在 [Key Vault] -> [存取原則] -> [應用程式] 底下,且 [秘密權限] 為 [設定]。

Screenshot shows the Recovery Services vault name is listed under Key Vault.

如果未列出,請再次設定權限

Azure Key Vault URI 不正確 - 100272

原因:輸入的 Key Vault URI 格式不正確。

建議的動作:請確保您是輸入從 Azure 入口網站複製的 Key Vault URI。 例如: https://myvault.vault.azure.net/

Screenshot shows how to copy Kay Vault URL.

UserErrorSecretExistsSoftDeleted (391282)

原因:預期格式的秘密已存在於 Key Vault 中,但處於虛刪除狀態。 若不還原秘密,MARS 無法將機器的複雜密碼儲存至提供的Key Vault。

建議的動作:檢查保存庫中是否有名稱為 AzBackup-<machine name>-<vaultname> 的秘密,以及是否處於虛刪除狀態。 請復原虛刪除的秘密,以將複雜密碼儲存到其中。

UserErrorKeyVaultSoftDeleted (391283)

原因:提供給 MARS 的 Key Vault 處於虛刪除狀態。

建議的動作:復原 Key Vault 或提供新的 Key Vault。

註冊不完整

原因:您未透過註冊複雜密碼來完成 MARS 註冊。 因此,在註冊之前您將無法設定備份。

建議的動作:選取警告訊息並完成註冊。

Screenshot shows how to complete the registration.