共用方式為


使用 az networkcloud cluster baremetalmachinekeyset 管理裸機電腦的緊急存取權

警告

請注意,當所有其他使用 Azure 的疑難解答選項都用盡時,此程式會在緊急情況下使用。 這些裸機電腦的 SSH 存取權,僅限於從指定跳板機清單透過此方法管理的使用者。

使用者需要調查及解決裸機機器的問題,以及透過 Azure 的所有其他方式都耗盡的情況。 Azure 運算子連接點提供 az networkcloud cluster baremetalmachinekeyset 命令,讓使用者可以管理這些裸機電腦的 SSH 存取權。 在密鑰集建立時,會針對 Microsoft Entra 識別碼來驗證使用者,以取得適當的授權,方法是交叉參考針對提供的 Microsoft Entra 群組識別碼 --azure-group-id <Entra Group ID>提供給使用者的用戶主體名稱。

密鑰集中的使用者會每隔四小時驗證一次,也會在對任何索引鍵集進行任何變更時進行驗證。 然後,每個使用者的狀態會設定為 「作用中」或「無效」。無效的使用者會保留在金鑰集中,但其密鑰會從所有主機中移除,且不允許存取。 使用者無效的原因如下:

  • 使用者的使用者主體名稱不是指定 Entra 群組的成員(如果指定)
  • 指定的 Entra 群組 (如果指定) 不存在 (在此情況下,索引鍵集中的所有使用者都無效)
  • 金鑰集已過期(在此情況下,金鑰集中的所有使用者都無效)

注意

目前正處於過渡期,可選擇指定使用者主體名稱與否。 未來版本會強制要求指定,而且所有使用者都必須接受 Microsoft Entra ID 驗證。 使用者不妨在過渡期結束 (計劃為 2024 年 7 月) 之前,將使用者主體名稱新增至其索引鍵集,以免索引鍵集失效。 請注意,如果將任何使用者主體名稱新增至索引鍵集,即使沒有為所有使用者新增名稱,也會啟用 Microsoft Entra ID 驗證,如果指定的群組識別碼無效,則會導致整個索引鍵集失效。

索引鍵集和每位個別使用者也有通訊其他資訊的詳細狀態消息:

  • 索引鍵集的詳細StatusMessage 會告訴您密鑰集是否已過期,以及更新整個叢集密鑰集時所發生問題的其他資訊。
  • 使用者的 statusMessage 會告訴您使用者是否作用中或無效,以及尚未更新為使用者最新作用中/無效狀態的計算機清單。 在每個案例中,如果已知,就會包含問題的原因。

命令執行時,會在叢集中具有作用中 Kube 節點的每部裸機電腦執行。 某協調程序會定期執行,如果原始命令無法使用,則會在任何裸機電腦重試命令。 此外,透過 az networkcloud baremetalmachine reimageaz networkcloud baremetalmachine replace 命令返回叢集的任何裸機電腦 (請參閱 BareMetal 函式) 會傳送訊號,因此裸機電腦一返回叢集,就將任何作用中索引鍵集傳送至電腦。 多個命令會依收到的順序執行。

群組中的使用者數目沒有限制。

警告

跳板機 IP 位址的注意事項

  • 索引鍵集建立/更新程序,會將跳板機 IP 位址新增至叢集中每部電腦的 IP 資料表。 IP 數據表更新會限制只能從這些跳躍主機允許 SSH 存取。
  • 請務必指定跳板機的叢集對應 IP 位址。 這些 IP 位址可能與用來存取跳板機的公用對應 IP 位址不同。
  • 雖然已定義至少一個金鑰集,但允許從任何金鑰集中的任何跳躍主機進行 SSH 存取。 例如,如果索引鍵集 A 指定跳躍主機 A,而索引鍵集 B 指定跳躍主機 B,則任一密鑰集中的使用者都可以使用跳躍主機 A 或 B。
  • 雖然未定義任何金鑰集,但允許從任何具有計算機網路連線的跳躍主機進行 SSH 存取。

必要條件

  • 安裝最新版本的適當 CLI 延伸模組
  • 內部部署叢集必須能夠連線到 Azure。
  • 取得 Cluster 資源的資源群組名稱。
  • 此程序會將索引鍵集套用至所有執行中裸機電腦。
  • 新增的使用者必須屬於 Microsoft Entra 群組。 如需詳細資訊,請參閱如何管理群組
  • 若要限制管理索引鍵集的存取權,請建立自訂角色。 如需詳細資訊,請參閱 Azure 自訂角色。 在此執行個體中,新增或排除 Microsoft.NetworkCloud/clusters/bareMetalMachineKeySets 的權限。 選項有 /read/write/delete

注意

透過本文所述的命令建立、修改或刪除裸機計算機存取權時,背景程式會將這些變更傳遞給機器。 此程序會在運算子連接點軟體升級期間暫停。 如果已知正在進行升級,您可以搭配命令使用 --no-wait 選項,以防命令提示字元等待程序完成。

建立裸機電腦索引鍵集

baremetalmachinekeyset create 命令會為一組使用者建立叢集中裸機電腦的 SSH 存取權。

命令語法為:

az networkcloud cluster baremetalmachinekeyset create \
  --name "<bare metal machine Keyset Name>" \
  --extended-location name="<Extended Location ARM ID>" \
    type="CustomLocation" \
  --location "<Azure Region>" \
  --azure-group-id "<Azure Group ID>" \
  --expiration "<Expiration Timestamp>" \
  --jump-hosts-allowed "<List of jump server IP addresses>" \
  --os-group-name "<Name of the Operating System Group>" \
  --privilege-level "<"Standard" or "Superuser">" \
  --user-list '[{"description":"<User List Description>","azureUserName":"<User Name>",\
    "sshPublicKey":{"keyData":"<SSH Public Key>"}, \
    "userPrincipalName":""}]', \
  --tags key1="<Key Value>" key2="<Key Value>" \
  --cluster-name "<Cluster Name>" \
  --resource-group "<cluster_RG>"

建立引數

  --azure-group-id                            [Required] : The object ID of Azure Active Directory
                                                           group that all users in the list must
                                                           be in for access to be granted. Users
                                                           that are not in the group do not have
                                                           access.
  --bare-metal-machine-key-set-name --name -n [Required] : The name of the bare metal machine key
                                                           set.
  --cluster-name                              [Required] : The name of the cluster.
  --expiration                                [Required] : The date and time after which the users
                                                           in this key set are removed from
                                                           the bare metal machines. The maximum
                                                           expiration date is a year from creation
                                                           date. Format is: "YYYY-MM-DDTHH:MM:SS.000Z".
  --extended-location                         [Required] : The extended location of the cluster
                                                           associated with the resource.
    Usage: --extended-location name=XX type=XX
      name: Required. The resource ID of the extended location on which the resource is created.
      type: Required. The extended location type: "CustomLocation".
  --jump-hosts-allowed                        [Required] : The list of IP addresses of jump hosts
                                                           with management network access from
                                                           which a login is be allowed for the
                                                           users. Supports IPv4 or IPv6 addresses.
  --privilege-level                           [Required] : The access level allowed for the users
                                                           in this key set.  Allowed values:
                                                           "Standard" or "Superuser".
  --resource-group -g                         [Required] : Name of cluster resource group. Optional if
                                                           configuring the default group using `az
                                                           configure --defaults group=<name>`.
  --user-list                                 [Required] : The unique list of permitted users.
    Usage: --user-list azure-user-name=XX description=XX key-data=XX
      azure-user-name: Required. User name used to login to the server.
      description: The free-form description for this user.
      key-data: Required. The public ssh key of the user.
      userPrincipalName: Optional. The User Principal Name of the User.

      Multiple users can be specified by using more than one --user-list argument.
  --os-group-name                                        : The name of the group that users are assigned
                                                           to on the operating system of the machines.
  --tags                                                 : Space-separated tags: key[=value]
                                                           [key[=value] ...]. Use '' to clear
                                                           existing tags.
  --location -l                                          : Azure Region. Values from: `az account
                                                           list-locations`. You can configure the
                                                           default location using `az configure
                                                           --defaults location=<location>`.
  --no-wait                                              : Do not wait for the long-running
                                                           operation to finish.

全域 Azure CLI 引數 (適用於所有命令)

  --debug                                                : Increase logging verbosity to show all
                                                           debug logs.
  --help -h                                              : Show this help message and exit.
  --only-show-errors                                     : Only show errors, suppressing warnings.
  --output -o                                            : Output format.  Allowed values: json,
                                                           jsonc, none, table, tsv, yaml, yamlc.
                                                           Default: json.
  --query                                                : JMESPath query string. See
                                                           http://jmespath.org/ for more
                                                           information and examples.
  --subscription                              [Required] : Name or ID of subscription. Optional if
                                                           configuring the default subscription
                                                           using `az account set -s NAME_OR_ID`.
  --verbose                                              : Increase logging verbosity. Use --debug
                                                           for full debug logs.

此範例會建立具有兩個使用者的新索引鍵集,讓使用者具有兩個跳板機的標準存取權。

az networkcloud cluster baremetalmachinekeyset create \
  --name "bareMetalMachineKeySetName" \
  --extended-location name="/subscriptions/subscriptionId/resourceGroups/cluster_RG/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName" \
    type="CustomLocation" \
  --location "eastus" \
  --azure-group-id "f110271b-XXXX-4163-9b99-214d91660f0e" \
  --expiration "2022-12-31T23:59:59.008Z" \
  --jump-hosts-allowed "192.0.2.1" "192.0.2.5" \
  --os-group-name "standardAccessGroup" \
  --privilege-level "Standard" \
  --user-list '[{"description":"Needs access for troubleshooting as a part of the support team","azureUserName":"userABC", "sshPublicKey":{"keyData":"ssh-rsa  AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1XoyYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm"},"userPrincipalName":"example@contoso.com"},\
  {"description":"Needs access for troubleshooting as a part of the support team","azureUserName":"userXYZ","sshPublicKey":{"keyData":"ssh-rsa  AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXTSTRnIDpcf5qytjs1XoyYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm"}, "userPrincipalName":"example@contoso.com"}]' \
  --tags key1="myvalue1" key2="myvalue2" \
  --cluster-name "clusterName"
  --resource-group "cluster_RG"

如需建立 --user-list 結構的協助,請參閱 Azure CLI 縮寫

刪除裸機電腦索引鍵集

baremetalmachinekeyset delete 命令會為一組使用者移除裸機電腦的 SSH 存取權。 群組的所有成員都不再具有叢集中任何裸機電腦的 SSH 存取權。

命令語法為:

az networkcloud cluster baremetalmachinekeyset delete \
  --name "<bare metal machine Keyset Name>" \
  --cluster-name "<Cluster Name>" \
  --resource-group "<cluster_RG>"

刪除引數

    --bare-metal-machine-key-set-name --name -n [Required] : The name of the bare metal machine key set to be
                                                             deleted.
    --cluster-name                              [Required] : The name of the cluster.
    --resource-group -g                         [Required] : Name of cluster resource group. Optional if configuring the
                                                             default group using `az configure --defaults
                                                             group=<name>`.
    --no-wait                                              : Do not wait for the long-running operation to
                                                             finish.
    --yes -y                                               : Do not prompt for confirmation.

此範例會移除 "clusterName" 叢集中的 "bareMetalMachineKeysetName" 索引鍵集群組。

az networkcloud cluster baremetalmachinekeyset delete \
  --name "bareMetalMachineKeySetName" \
  --cluster-name "clusterName" \
  --resource-group "cluster_RG"

更新裸機電腦索引鍵集

baremetalmachinekeyset update 命令可讓使用者變更現有的索引鍵集群組。

命令語法為:

az networkcloud cluster baremetalmachinekeyset update \
  --name "<bare metal machine Keyset Name>" \
  --jump-hosts-allowed "<List of jump server IP addresses>" \
  --privilege-level "<"Standard" or "Superuser">" \
  --user-list '[{"description":"<User List Description>","azureUserName":"<User Name>",\
   "sshPublicKey":{"keyData":"<SSH Public Key>"}, \
   "userPrincipalName":""}]', \
  --tags key1="<Key Value>" key2="<Key Value> "\
  --cluster-name "<Cluster Name>" \
  --resource-group "<cluster_RG>"

更新引數

  --bare-metal-machine-key-set-name --name -n [Required] : The name of the bare metal machine key set.
  --cluster-name                              [Required] : The name of the cluster.
  --expiration                                           : The date and time after which the users
                                                           in this key set are removed from
                                                           the bare metal machines. The maximum
                                                           expiration date is a year from creation
                                                           date. Format is: "YYYY-MM-DDTHH:MM:SS.000Z".
  --jump-hosts-allowed                                   : The list of IP addresses of jump hosts
                                                           with management network access from
                                                           which a login is allowed for the
                                                           users. Supports IPv4 or IPv6 addresses.
  --privilege-level                                      : The access level allowed for the users
                                                           in this key set.  Allowed values:
                                                           "Standard" or "Superuser".
  --user-list                                            : The unique list of permitted users.
    Usage: --user-list azure-user-name=XX description=XX key-data=XX
      azure-user-name: Required. User name used to login to the server.
      description: The free-form description for this user.
      key-data: Required. The public SSH key of the user.
      userPrincipalName: Optional. The User Principal Name of the User.

      Multiple users can be specified by using more than one --user-list argument.
  --resource-group -g                         [Required] : Name of cluster resource group. Optional if
                                                           configuring the default group using `az
                                                           configure --defaults group=<name>`.
  --tags                                                 : Space-separated tags: key[=value]
                                                           [key[=value] ...]. Use '' to clear
                                                           existing tags.
  --no-wait                                              : Do not wait for the long-running
                                                           operation to finish.

此範例會將兩個新的使用者新增至 "baremetalMachineKeySetName"群組,並且變更群組的到期時間。

az networkcloud cluster baremetalmachinekeyset update \
  --name "bareMetalMachineKeySetName" \
 --expiration "2023-12-31T23:59:59.008Z" \
  --user-list '[{"description":"Needs access for troubleshooting as a part of the support team",\
  "azureUserName":"userABC", \
  "sshPublicKey":{"keyData":"ssh-rsa  AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1XoyYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm"}, \
  "userPrincipalName":"example@contoso.com"},\
  {"description":"Needs access for troubleshooting as a part of the support team",\
    "azureUserName":"userXYZ", \
    "sshPublicKey":{"keyData":"ssh-rsa  AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXTSTRnIDpcf5qytjs1XoyYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm"}, \
    "userPrincipalName":"example@contoso.com"}]' \
   --cluster-name "clusterName" \
  --resource-group "cluster_RG"

列出裸機電腦索引鍵集

baremetalmachinekeyset list 命令可讓使用者查看叢集中現有的索引鍵集群組。

命令語法為:

az networkcloud cluster baremetalmachinekeyset list \
  --cluster-name "<Cluster Name>" \
  --resource-group "<cluster_RG>"

列出引數

  --cluster-name                              [Required] : The name of the cluster.
  --resource-group -g                         [Required] : Name of cluster resource group. Optional if
                                                           configuring the default group using `az
                                                           configure --defaults group=<name>`.

顯示裸機電腦索引鍵集詳細資料

baremetalmachinekeyset show 命令可讓使用者查看叢集中現有索引鍵集群組的詳細資料。

命令語法為:

az networkcloud cluster baremetalmachinekeyset show \
  --cluster-name "<Cluster Name>" \
  --resource-group "<cluster_RG>"

顯示引數

  --bare-metal-machine-key-set-name --name -n [Required] : The name of the bare metal machine key
                                                           set.
  --cluster-name                              [Required] : The name of the cluster.
  --resource-group -g                         [Required] : Name of cluster resource group. You can
                                                           configure the default group using `az
                                                           configure --defaults group=<name>`.