配置 Microsoft Entra Kerberos 信任

Microsoft Entra Kerberos 信任建立入站信任关系,其中本地Active Directory 域服务(AD DS)信任Microsoft Entra ID作为 Kerberos 密钥分发中心(KDC)。 此信任使混合标识组织能够对应用程序使用新式凭据,并允许Microsoft Entra ID成为云和本地身份验证的受信任源。

本文介绍如何创建受信任的域对象、配置客户端以检索 Kerberos 票证、轮换 Kerberos 密钥以及删除信任配置。

Prerequisites

若要完成本文中的步骤,需要:

  • 已加入Active Directory的受支持Windows客户端。 域必须具有Windows Server 2012或更高版本的功能级别。
  • 本地 Active Directory管理员帐户,该帐户是域的域管理员组的成员,或者是林的企业管理员组的成员。
  • Microsoft Entra全局管理员帐户。
  • 在本地 AD DS 与Microsoft Entra ID之间同步的混合标识。

创建和配置 Microsoft Entra Kerberos 受信任域对象

若要创建和配置 Microsoft Entra Kerberos 受信任的域对象,请使用 Azure AD 混合身份验证管理 PowerShell 模块。

用 Microsoft Entra ID 注册受信任域对象

使用 Azure AD 混合身份验证管理 PowerShell 模块在Active Directory域中设置受信任的域对象,并将信任信息注册到Microsoft Entra ID。 此操作将创建入站信任关系,使本地 Active Directory能够信任Microsoft Entra ID。

只需为每个域设置一次受信任的域对象。 如果已为域设置此对象,请跳过本部分,并继续 配置客户端以检索 Kerberos 票证。

安装 Azure AD 混合身份验证管理 PowerShell 模块

  1. 使用 “以管理员身份运行 ”选项启动 Windows PowerShell 会话。

  2. 使用以下脚本安装 Azure AD 混合身份验证管理 PowerShell 模块。 脚本:

    1. 启用 TLS 1.2 进行通信。
    2. 安装 NuGet 包提供程序。
    3. 如果尚未注册,则注册 PSGallery 存储库。
    4. 将 PSGallery 配置为受信任的存储库。
    5. 安装 PowerShellGet 模块。
    6. 安装 Azure AD 混合身份验证管理 PowerShell 模块。

    Azure AD 混合身份验证管理 PowerShell 模块使用 AzureADPreview 模块,该模块提供高级Microsoft Entra管理功能。 为了防止与 Azure AD PowerShell 模块发生不必要的安装冲突,安装命令包括参数-AllowClobber。

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    
    Install-PackageProvider -Name NuGet -Force
    
    if (@(Get-PSRepository | Where-Object { $_.Name -eq "PSGallery" }).Count -eq 0) {
        Register-PSRepository -Default
    }
    
    Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
    
    Install-Module -Name PowerShellGet -Force
    
    Install-Module -Name AzureADHybridAuthenticationManagement -AllowClobber
    

设置受信任的域对象

  1. 使用 “以管理员身份运行 ”选项启动 Windows PowerShell 会话。

  2. 设置通用参数。 在运行脚本之前对其进行自定义。

    1. 将 $domain 参数设置为本地 Active Directory 域名。
    2. 当 Get-Credential 提示你时,输入本地 Active Directory 管理员帐户的凭据。 该帐户必须满足 先决条件中所述的权限。
    3. 将$cloudUserName参数设置为Microsoft Entra全局管理员帐户的用户主体名称。

    注释

    若要使用当前 Windows 登录帐户进行本地 Active Directory 访问,请不要将凭据分配给$domainCred,并省略本文中 PowerShell 命令里的-DomainCredential参数。

    $domain = "your on-premises domain name, for example contoso.com"
    $domainCred = Get-Credential
    $cloudUserName = "Microsoft Entra ID user principal name, for example admin@contoso.partner.onmschina.cn"
    
  3. 检查当前的 Kerberos 域设置:

    Get-AzureADKerberosServer -Domain $domain `
        -DomainCredential $domainCred `
        -UserPrincipalName $cloudUserName
    

    首次调用 Microsoft Entra Kerberos 命令时,系统会提示你授予 Microsoft Entra ID 访问权限。 输入你的 Microsoft Entra 全局管理员帐户密码。 如果你的组织使用另一种新式身份验证方法(例如Microsoft Entra多重身份验证或智能卡),请按照登录说明进行操作。

    如果未配置 Microsoft Entra Kerberos,则 Get-AzureADKerberosServer cmdlet 将显示空信息:

    ID                  :
    UserAccount         :
    ComputerAccount     :
    DisplayName         :
    DomainDnsName       :
    KeyVersion          :
    KeyUpdatedOn        :
    KeyUpdatedFrom      :
    CloudDisplayName    :
    CloudDomainDnsName  :
    CloudId             :
    CloudKeyVersion     :
    CloudKeyUpdatedOn   :
    CloudTrustDisplay   :
    

    如果域已支持 FIDO2 安全密钥身份验证,则 cmdlet 会显示Microsoft Entra服务帐户信息。 字段 CloudTrustDisplay 为空:

    ID                  : XXXXX
    UserAccount         : CN=krbtgt-AzureAD, CN=Users, DC=contoso, DC=com
    ComputerAccount     : CN=AzureADKerberos, OU=Domain Controllers, DC=contoso, DC=com
    DisplayName         : XXXXXX_XXXXX
    DomainDnsName       : contoso.com
    KeyVersion          : 53325
    KeyUpdatedOn        : 2/24/2024 9:03:15 AM
    KeyUpdatedFrom      : ds-aad-auth-dem.contoso.com
    CloudDisplayName    : XXXXXX_XXXXX
    CloudDomainDnsName  : contoso.com
    CloudId             : XXXXX
    CloudKeyVersion     : 53325
    CloudKeyUpdatedOn   : 2/24/2024 9:03:15 AM
    CloudTrustDisplay   :
    
  4. 添加受信任的域对象。

    使用 -SetupCloudTrust 参数运行 Set-AzureADKerberosServer cmdlet。 如果Microsoft Entra服务帐户不存在,此命令将创建一个。 该命令仅在Microsoft Entra服务帐户可用时创建受信任的域对象。

    Set-AzureADKerberosServer -Domain $domain `
        -UserPrincipalName $cloudUserName `
        -DomainCredential $domainCred `
        -SetupCloudTrust
    

    注释

    在多域林中,执行以下步骤以避免在子域上运行命令时出现 LsaCreateTrustedDomainEx 0x549 错误:

    1. 使用 -SetupCloudTrust 参数对根域运行该命令。
    2. 在不使用 -SetupCloudTrust 参数的情况下,在子域上运行相同命令。

    创建受信任的域对象后,使用 Get-AzureADKerberosServer 检查更新后的 Kerberos 设置。 Set-AzureADKerberosServer当 cmdlet 使用-SetupCloudTrust参数成功完成时,字段CloudTrustDisplay返回Microsoft.AzureAD.Kdc.Service.TrustDisplay:

    ID                  : XXXXX
    UserAccount         : CN=krbtgt-AzureAD, CN=Users, DC=contoso, DC=com
    ComputerAccount     : CN=AzureADKerberos, OU=Domain Controllers, DC=contoso, DC=com
    DisplayName         : XXXXXX_XXXXX
    DomainDnsName       : contoso.com
    KeyVersion          : 53325
    KeyUpdatedOn        : 2/24/2024 9:03:15 AM
    KeyUpdatedFrom      : ds-aad-auth-dem.contoso.com
    CloudDisplayName    : XXXXXX_XXXXX
    CloudDomainDnsName  : contoso.com
    CloudId             : XXXXX
    CloudKeyVersion     : 53325
    CloudKeyUpdatedOn   : 2/24/2024 9:03:15 AM
    CloudTrustDisplay   : Microsoft.AzureAD.Kdc.Service.TrustDisplay
    

    注释

    Azure 主权云要求你设置 TopLevelNames 属性,该属性默认设置为 windows.net。 某些主权云服务使用不同的顶级域名。 将受信任的域对象设置为所需的顶级域名:

    Set-AzureADKerberosServer -Domain $domain `
        -DomainCredential $domainCred `
        -UserPrincipalName $cloudUserName `
        -SetupCloudTrust `
        -TopLevelNames "chinacloudapi.cn"
    

    验证以下设置:

    Get-AzureADKerberosServer -Domain $domain `
        -DomainCredential $domainCred `
        -UserPrincipalName $cloudUserName |
        Select-Object -ExpandProperty CloudTrustDisplay
    

配置客户端以检索 Kerberos 票证

确定Microsoft Entra 租户 ID,并使用组策略配置需要检索 Microsoft Entra Kerberos 票证的每个客户端。

将 管理模板\系统\Kerberos\指定 Kerberos 客户端的 KDC 代理服务器 设置为 “已启用”:

  1. 编辑“管理模板\系统\Kerberos\指定 Kerberos 客户端的 KDC 代理服务器”策略设置。

  2. 选择启用。

  3. 在“选项”下,选择“显示...”。

  4. 定义下表中显示的 KDC 代理服务器映射。 将 your_Microsoft_Entra_tenant_ID 替换为你的租户 ID。 在值中包含位于 之后且位于闭合 之前的空格。

    值名称 Value
    KERBEROS.MICROSOFTONLINE.COM <https login.partner.microsoftonline.cn:443:your_Microsoft_Entra_tenant_ID/kerberos />
  5. 选择“确定”关闭“显示内容”对话框。

  6. 在“指定 Kerberos 客户端的 KDC 代理服务器”对话框中选择“应用”。

轮换 Kerberos 密钥

Microsoft Entra Kerberos 在本地 AD DS 和 Microsoft Entra ID之间使用共享 Kerberos 服务器密钥。 该密钥对Microsoft Entra ID颁发的票证授予票证(TGT)进行加密和保护。 它存储在本地 Active Directory中的专用 Microsoft Entra Kerberos 服务器对象上,并安全地发布到Microsoft Entra ID。 此对象是逻辑的,不是物理服务器,其功能类似于 Kerberos 信任的只读域控制器 (RODC)。

定期轮换Microsoft Entra服务帐户和受信任的域对象的密钥。 常规轮换:

  • 限制密码材料的生存期。
  • 如果密钥遭到入侵,可降低风险。
  • 符合标准 Kerberos 和Active Directory安全做法。

Microsoft 不要求一个固定的轮换周期。 在计划的安全维护时段内,按照与其他Active Directory Kerberos (krbtgt) 密钥相同的计划轮换 Microsoft Entra Kerberos 服务器密钥,并在可疑凭据泄露后立即轮换。

密钥轮换的工作原理

Microsoft Entra Kerberos 使用双键模型来避免轮换期间的服务中断:

  • 主密钥:加密所有新颁发的 Kerberos 票证。
  • 辅助密钥:保留上一个密钥以验证现有票证,直到其过期。

轮换该密钥时,新密钥将成为主密钥,而以前的主密钥将成为辅助密钥。 Microsoft Entra ID 对新的 Kerberos 票证使用主密钥,并继续接受受辅助密钥保护的票证。 此过程不会中断用户访问。

轮换密钥

使用 Set-AzureADKerberosServer cmdlet 轮换密钥。 命令:

  • 生成新的 Kerberos 服务器密钥。
  • 将密钥存储在 本地 Active Directory Kerberos 服务器对象上。
  • 安全地将密钥发布到 Microsoft Entra ID。
  • 更新两个环境中的密钥版本。
Set-AzureADKerberosServer -Domain $domain `
    -DomainCredential $domainCred `
    -UserPrincipalName $cloudUserName `
    -SetupCloudTrust `
    -RotateServerKey

Warning

其他工具可以轮换krbtgt密钥,但必须为 Microsoft Entra Kerberos 服务器使用 Set-AzureADKerberosServer cmdlet。 此 cmdlet 可确保在本地 Active Directory和Microsoft Entra ID中更新密钥。

轮换密钥后,需要等待几个小时,以便更改后的密钥在 Kerberos KDC 服务器之间传播。 由于此密钥分发时间安排,可以在 24 小时内轮换密钥一次。

Important

若要完全停用旧密钥,请在原始主密钥和辅助密钥及其票证均已过期后执行两次轮换。

使用 -Force 参数

如果需要在 24 小时内再次轮换密钥,例如在创建受信任的域对象后立即,请添加 -Force 参数:

Set-AzureADKerberosServer -Domain $domain `
    -DomainCredential $domainCred `
    -UserPrincipalName $cloudUserName `
    -SetupCloudTrust `
    -RotateServerKey `
    -Force

该 -Force 参数在维护安全控制的同时应用或更新 Kerberos 服务器配置,而无需确认提示。 在以下情况下使用:

  • 需要在24小时内再次转动钥匙。
  • 重新运行命令以修复或使配置一致。
  • 您可以自动执行 Kerberos 设置或密钥管理。
  • 您可从部分或失败的配置尝试中恢复。
  • 需要确保跨环境保持一致的状态,而无需手动确认。

删除受信任的域对象

删除受信任的域对象:

Remove-AzureADKerberosServerTrustedDomainObject -Domain $domain `
    -DomainCredential $domainCred `
    -UserPrincipalName $cloudUserName

此命令仅删除受信任的域对象。 如果域支持 FIDO2 安全密钥身份验证,则可以在维护该身份验证服务所需的Microsoft Entra服务帐户的同时删除该对象。

删除所有 Kerberos 设置

删除Microsoft Entra服务帐户和受信任的域对象:

Remove-AzureADKerberosServer -Domain $domain `
    -DomainCredential $domainCred `
    -UserPrincipalName $cloudUserName