تكوين Bastion لمصادقة Kerberos باستخدام مدخل Microsoft Azure

توضح لك هذه المقالة كيفية تكوين Azure Bastion لاستخدام مصادقة Kerberos. يمكن استخدام مصادقة Kerberos مع كل من وحدات SKU الأساسية والقياسية Bastion. لمزيد من المعلومات حول مصادقة Kerberos، راجع نظرة عامة على مصادقة Kerberos. لمعرفة مزيد من المعلومات بخصوص Azure Bastion، راجع ما هو Azure Bastion؟

الاعتبارات

  • يمكن تكوين إعداد Kerberos ل Azure Bastion في مدخل Microsoft Azure فقط وليس مع العميل الأصلي.
  • الأجهزة الظاهرية التي تم ترحيلها من أماكن العمل إلى Azure غير مدعومة حاليا ل Kerberos. 
  • المصادقة عبر النطاقات غير مدعومة حاليا ل Kerberos.
  • يجب أن تكون وحدة التحكم بالمجال جهازا ظاهريا مستضافا من Azure داخل نفس VNET الذي يتم نشر الأساس.
  • التغييرات على خادم DNS غير مدعومة حاليا ل Kerberos. بعد إجراء أي تغييرات على خادم DNS، ستحتاج إلى حذف مورد Bastion وإعادة إنشائه.
  • إذا تمت إضافة وحدة تحكم بالمجال إضافية (وحدات التحكم بالمجال)، فسيتعرف Bastion فقط على وحدة التحكم بالمجال الأولى.
  • إذا تمت إضافة DCs إضافية لمجالات مختلفة، فلا يمكن للمجالات المضافة المصادقة بنجاح مع Kerberos.

المتطلبات الأساسية

  • حساب Azure مع اشتراك نشط. في حالة عدم امتلاك حساب، أنشئ حساباً مجانياً. حتى تكون قادراً على الاتصال بجهاز ظاهري من خلال متصفحك باستخدام Bastion، يجب أن تكون قادراً على تسجيل الدخول إلى مدخل Microsoft Azure.

  • شبكة Azure الظاهرية. للحصول على خطوات لإنشاء شبكة ظاهرية، راجع التشغيل السريع: إنشاء شبكة ظاهرية.

تحديث خوادم VNet DNS

في هذا القسم، تساعدك الخطوات التالية على تحديث الشبكة الظاهرية لتحديد إعدادات DNS المخصصة.

  1. قم بتسجيل الدخول إلى بوابة Azure.
  2. انتقل إلى الشبكة الظاهرية التي تريد توزيع موارد Bastion لها.
  3. انتقل إلى صفحة خوادم DNS للشبكة الظاهرية وحدد Custom. أضف عنوان IP لوحدة تحكم المجال المستضافة في Azure وانقر على حفظ.

توزيع Bastion

  1. ابدأ في تكوين توزيع bastion الخاص بك باستخدام الخطوات الواردة في البرنامج التعليمي: توزيع Bastion باستخدام إعدادات التكوين اليدوي. تكوين الإعدادات في علامة التبويب Basics. بعد ذلك، في أعلى الصفحة، انقر فوق خيارات متقدمة للانتقال إلى علامة التبويب خيارات متقدمة.

  2. في علامة التبويب Advanced، حدد Kerberos.

    Screenshot of select bastion features.

  3. في أسفل الصفحة، حدد Review + create، ثم Create لتوزيع Bastion إلى شبكتك الظاهرية.

  4. بمجرد اكتمال النشر، يمكنك استخدامه لتسجيل الدخول إلى أي أجهزة Windows ظاهرية يمكن الوصول إليها مرتبطة بـ DNS المخصص الذي حددته في الخطوات السابقة.

لتعديل مضيف bastion موجود بالفعل

في هذا القسم، تساعدك الخطوات التالية على تعديل شبكتك الظاهرية ونشر Bastion الحالي لمصادقة Kerberos.

  1. حدث إعدادات نظام أسماء المجالات في الشبكة الظاهرية
  2. انتقل إلى صفحة المدخل لنشر Bastion وحدد Configuration.
  3. في صفحة التكوين، حدد Kerberos authentication، ثم حدد Apply.
  4. تحديثات Bastion بإعدادات التكوين الجديدة.

للتحقق من أن Bastion يستخدم Kerberos

إشعار

يجب استخدام اسم المستخدم الأساسي (UPN) لتسجيل الدخول باستخدام Kerberos.

بمجرد تمكين Kerberos على مورد Bastion الخاص بك، يمكنك التحقق من أنه يستخدم بالفعل Kerberos للمصادقة على الجهاز الظاهري المستهدف المرتبط بالمجال.

  1. تسجيل الدخول إلى الجهاز الظاهري الهدف (إما عبر Bastion أو لا). ابحث عن "تحرير نهج المجموعة" من شريط المهام وافتح Local Group Policy Editor.

  2. حدد Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options.

  3. ابحث عن Networking security: Restrict NTLM: Incoming NTLM Traffic وقم بتعيينها إلى Deny all domain accounts. نظرًا إلى أن Bastion يستخدم NTLM للمصادقة عند تعطيل Kerberos، يضمن هذا الإعداد أن المصادقة المستندة إلى NTLM غير ناجحة لمحاولات تسجيل الدخول المستقبلية على الجهاز الظاهري.

  4. قم بإنهاء جلسة VM.

  5. قم بالاتصال بالجهاز الظاهري الهدف مرة أخرى باستخدام Bastion. يجب أن ينجح تسجيل الدخول، مما يشير إلى أن Bastion استخدم Kerberos (وليس NTLM) للمصادقة.

    إشعار

    لمنع إرجاع الموارد إلى NTLM، تأكد من اتباع الخطوات السابقة. لن يؤدي تمكين Kerberos (دون اتباع الإجراء) إلى منع إرجاع الموارد إلى NTLM.

التشغيل السريع: إعداد Bastion باستخدام Kerberos - قالب Resource Manager

مراجعة القالب

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "location": {
      "defaultValue": "[resourceGroup().location]",
      "type": "string"
    },
    "defaultNsgName": {
      "type": "string",
      "defaultValue": "Default-nsg"
    },
    "VnetName": {
      "type": "string",
      "defaultValue": "myVnet"
    },
    "ClientVMName": {
      "defaultValue": "Client-vm",
      "type": "string"
    },
    "ServerVMName": {
      "defaultValue": "Server-vm",
      "type": "string"
    },
    "vmsize": {
      "defaultValue": "Standard_DS1_v2",
      "type": "string",
      "metadata": {
        "description": "VM SKU to deploy"
      }
    },
    "ServerVMUsername": {
      "type": "string",
      "defaultValue": "serveruser",
      "metadata": {
        "description": "Admin username on all VMs."
      }
    },
    "ServerVMPassword": {
      "type": "securestring",
      "metadata": {
        "description": "Admin password on all VMs."
      }
    },
    "SafeModeAdministratorPassword": {
      "type": "securestring",
      "metadata": {
        "description": "See https://learn.microsoft.com/en-us/powershell/module/addsdeployment/install-addsdomaincontroller?view=windowsserver2022-ps#-safemodeadministratorpassword"
      }
    },
    "ClientVMUsername": {
      "type": "string",
      "defaultValue": "clientuser",
      "metadata": {
        "description": "username on ClientVM."
      }
    },
    "ClientVMPassword": {
      "type": "securestring",
      "metadata": {
        "description": "password on ClientVM."
      }
    },
    "ServerVmImage": {
      "type": "object",
      "defaultValue": {
        "offer": "WindowsServer",
        "publisher": "MicrosoftWindowsServer",
        "sku": "2019-Datacenter",
        "version": "latest"
      }
    },
    "ClientVmImage": {
      "type": "object",
      "defaultValue": {
        "offer": "Windows",
        "publisher": "microsoftvisualstudio",
        "sku": "Windows-10-N-x64",
        "version": "latest"
      }
    },
    "publicIPAllocationMethod": {
      "type": "string",
      "defaultValue": "Static"
    },
    "BastionName": {
      "defaultValue": "Bastion",
      "type": "string"
    },
    "BastionPublicIPName": {
        "defaultValue": "Bastion-ip",
        "type": "string"
    }
  },
  "variables": {
    "DefaultSubnetId": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('VnetName')), '/subnets/default')]",
    "ClientVMSubnetId": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('VnetName')), '/subnets/clientvm-subnet')]",
    "DNSServerIpAddress": "10.16.0.4",
    "ClientVMPrivateIpAddress": "10.16.1.4"
  },
  "resources": [
    {
      "apiVersion": "2020-03-01",
      "name": "[parameters('VnetName')]",
      "type": "Microsoft.Network/virtualNetworks",
      "location": "[parameters('location')]",
      "properties": {
        "dhcpOptions": {
          "dnsServers": [ "[variables('DNSServerIpAddress')]" ]
        },
        "subnets": [
          {
            "name": "default",
            "properties": {
              "addressPrefix": "10.16.0.0/24"
            }
          },
          {
            "name": "clientvm-subnet",
            "properties": {
              "addressPrefix": "10.16.1.0/24"
            }
          },
          {
            "name": "AzureBastionSubnet",
            "properties": {
              "addressPrefix": "10.16.2.0/24"
            }
          }
        ],
        "addressSpace": {
          "addressPrefixes": [
            "10.16.0.0/16"
          ]
        }
      }
    },
    {
      "type": "Microsoft.Network/networkInterfaces",
      "apiVersion": "2018-10-01",
      "name": "[concat(parameters('ServerVMName'), 'Nic')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Network/virtualNetworks/', parameters('VnetName'))]"
      ],
      "properties": {
        "ipConfigurations": [
          {
            "name": "[concat(parameters('ServerVMName'), 'NicIpConfig')]",
            "properties": {
              "privateIPAllocationMethod": "Static",
              "privateIPAddress": "[variables('DNSServerIpAddress')]",
              "subnet": {
                "id": "[variables('DefaultSubnetId')]"
              }
            }
          }
        ]
      }
    },
    {
      "type": "Microsoft.Compute/virtualMachines",
      "apiVersion": "2020-06-01",
      "name": "[parameters('ServerVMName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Network/networkInterfaces/', parameters('ServerVMName'), 'Nic')]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('vmSize')]"
        },
        "osProfile": {
          "AdminUsername": "[parameters('ServerVMUsername')]",
          "AdminPassword": "[parameters('ServerVMPassword')]",
          "computerName": "[parameters('ServerVMName')]"
        },
        "storageProfile": {
          "imageReference": "[parameters('ServerVmImage')]",
          "osDisk": {
            "createOption": "FromImage",
            "managedDisk": {
              "storageAccountType": "Standard_LRS"
            }
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[ResourceId('Microsoft.Network/networkInterfaces/', concat(parameters('ServerVMName'), 'Nic'))]"
            }
          ]
        }
      }
    },
    {
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('ServerVMName'),'/', 'PromoteToDomainController')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachines/',parameters('ServerVMName'))]"
      ],
      "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.7",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "commandToExecute": "[concat('powershell.exe -Command \"Install-windowsfeature AD-domain-services; Import-Module ADDSDeployment;$Secure_String_Pwd = ConvertTo-SecureString ',parameters('SafeModeAdministratorPassword'),' -AsPlainText -Force; Install-ADDSForest -DomainName \"bastionkrb.test\" -SafeModeAdministratorPassword $Secure_String_Pwd -Force:$true')]"
          }
      }
    },
    {
      "type": "Microsoft.Network/networkInterfaces",
      "apiVersion": "2018-10-01",
      "name": "[concat(parameters('ClientVMName'), 'Nic')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Network/virtualNetworks/', parameters('VnetName'))]",
        "[concat('Microsoft.Compute/virtualMachines/', parameters('ServerVMName'))]"
      ],
      "properties": {
        "ipConfigurations": [
          {
            "name": "[concat(parameters('ClientVMName'), 'NicIpConfig')]",
            "properties": {
              "privateIPAllocationMethod": "Static",
              "privateIPAddress": "[variables('ClientVMPrivateIpAddress')]",
              "subnet": {
                "id": "[variables('ClientVMSubnetId')]"
              }
            }
          }
        ]
      }
    },
    {
      "type": "Microsoft.Compute/virtualMachines",
      "apiVersion": "2020-06-01",
      "name": "[parameters('ClientVMName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Network/networkInterfaces/', parameters('ClientVMName'), 'Nic')]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('vmSize')]"
        },
        "osProfile": {
          "AdminUsername": "[parameters('ClientVMUsername')]",
          "AdminPassword": "[parameters('ClientVMPassword')]",
          "computerName": "[parameters('ClientVMName')]"
        },
        "storageProfile": {
          "imageReference": "[parameters('ClientVmImage')]",
          "osDisk": {
            "createOption": "FromImage",
            "managedDisk": {
              "storageAccountType": "Standard_LRS"
            }
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[ResourceId('Microsoft.Network/networkInterfaces/', concat(parameters('ClientVMName'), 'Nic'))]"
            }
          ]
        }
      }
    },
    {
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "apiVersion": "2021-04-01",
      "name": "[concat(parameters('ClientVMName'),'/', 'DomainJoin')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachines/',parameters('ClientVMName'))]",
        "[concat('Microsoft.Compute/virtualMachines/', parameters('ServerVMName'),'/extensions/', 'PromoteToDomainController')]",
        "[concat('Microsoft.Network/bastionHosts/', parameters('BastionName'))]"
      ],
      "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.7",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "commandToExecute": "[concat('powershell.exe -Command Set-ItemProperty -Path HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Lsa\\MSV1_0\\ -Name RestrictReceivingNTLMTraffic -Value 1; $Pass= ConvertTo-SecureString -String ',parameters('ServerVMPassword'),' -AsPlainText -Force; $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList \"AD\\serveruser\", $Pass; do { try { $joined = add-computer -computername Client-vm -domainname bastionkrb.test –credential $Credential -passthru -restart –force; } catch {}} while ($joined.HasSucceeded -ne $true)')]"
          }
      }
    },
    {
      "apiVersion": "2020-11-01",
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[parameters('BastionPublicIPName')]",
      "location": "[resourceGroup().location]",
      "sku": {
        "name": "Standard"
      },
      "properties": {
        "publicIPAllocationMethod": "Static"
      },
      "tags": {}
    },
    {
        "type": "Microsoft.Network/bastionHosts",
        "apiVersion": "2020-11-01",
        "name": "[parameters('BastionName')]",
        "location": "[resourceGroup().location]",
        "dependsOn": [
            "[concat('Microsoft.Network/virtualNetworks/', parameters('VnetName'))]",
            "[concat('Microsoft.Network/publicIpAddresses/', parameters('BastionPublicIPName'))]"
        ],
        "sku": {
            "name": "Standard"
        },
        "properties": {
            "enableKerberos": "true",
            "ipConfigurations": [
                {
                    "name": "IpConf",
                    "properties": {
                        "privateIPAllocationMethod": "Dynamic",
                        "publicIPAddress": {
                            "id": "[resourceId('Microsoft.Network/publicIpAddresses', parameters('BastionPublicIPName'))]"
                        },
                        "subnet": {
                            "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('VnetName')), '/subnets/AzureBastionSubnet')]"
                        }
                    }
                }
            ]
        }
    }
  ]
}

تم تحديد الموارد التالية في القالب:

  • توزيع موارد Azure التالية:
  • ادفع خادم DNS الخاص بالشبكة الظاهرية إلى عنوان IP الخاص ل ServerVM (وحدة تحكم المجال).
  • تشغيل ملحق البرنامج النصي المخصص على ServerVM للترويج له إلى وحدة تحكم بالمجال باسم المجال: bastionkrb.test.
  • تشغيل ملحق البرنامج النصي المخصص على ClientVM للحصول عليه:
    • تقييد NTLM: حركة مرور NTLM الواردة = رفض جميع حسابات المجال (هذا لضمان استخدام Kerberos للمصادقة).
    • الانضمام إلى bastionkrb.test المجال.

نشر القالب

لإعداد Kerberos، انشر قالب ARM السابق عن طريق تشغيل PowerShell cmd التالي:

New-AzResourceGroupDeployment -ResourceGroupName <your-rg-name> -TemplateFile "<path-to-template>\KerberosDeployment.json"`

مراجعة الموارد الموزعة

الآن، سجل الدخول إلى ClientVM باستخدام Bastion مع مصادقة Kerberos:

  • بيانات الاعتماد: اسم المستخدم = serveruser@bastionkrb.test وكلمة المرور = <password-entered-during-deployment>.

الخطوات التالية

لمعرفة مزيد من المعلومات بخصوص Azure Bastion، راجع ما هو Azure Bastion؟