Share via


使用管理裸機計算機的緊急存取 az networkcloud cluster bmckeyset

警告

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

使用者需要調查和解決裸機機器的問題,以及使用 Azure 的所有其他方式都已耗盡的情況。 操作員 Nexus 提供 az networkcloud cluster bmckeyset 命令,讓使用者可以管理這些裸機機器上基板管理控制器 (BMC) 的 SSH 存取權。 在密鑰集建立時,會針對 Microsoft Entra ID 驗證使用者,以取得適當的授權,方法是交叉參考針對提供的 Azure 群組識別碼 --azure-group-id <Entra Group ID>提供給使用者的使用者主體名稱。

如果使用者的用戶主體名稱不是所提供群組的成員,則使用者的狀態會設定為 「無效」,而其狀態消息會指出「無效,因為 userPrincipal 不是 AAD 群組的成員」。如果 Azure 群組識別碼無效,金鑰集中的每個使用者的狀態設定為 「無效」,而其狀態消息會指出「AAD 群組不存在」。無效的使用者會保留在金鑰集中,但不會啟用其金鑰以進行 SSH 存取。

注意

目前有一個過渡期,其中指定用戶主體名稱是選擇性的。 在未來版本中,它將會變成強制,而且所有使用者都將強制執行 Microsoft Entra ID 驗證。 鼓勵使用者在過渡期間結束之前將用戶主體名稱新增至其密鑰集(計劃於 2024 年 7 月),以避免金鑰集失效。 請注意,如果將任何用戶主體名稱新增至密鑰集,即使未針對所有使用者新增名稱,也會啟用 Microsoft Entra ID 驗證,如果指定的群組標識符無效,這會導致整個密鑰集失效。

當命令執行時,它會在叢集中具有作用中 Kubernetes 節點的每個裸機電腦上執行。 有一個對帳程式會定期執行,以在原始命令時無法使用的任何裸機計算機上重試命令。 此外,任何透過 az networkcloud baremetalmachine actionreimageaz networkcloud baremetalmachine actionreplace 命令傳回叢集的裸機電腦(請參閱 BareMetal函式)都會傳送訊號,讓任何作用中索引鍵集在返回叢集時立即傳送至計算機。 多個命令會依收到的順序執行。

BMC 支援最多12位使用者。 用戶會根據每個叢集定義,並套用至每個裸機計算機。 嘗試新增超過12個使用者會導致錯誤。 當 12 已經存在時,請先刪除使用者,再新增另一個使用者。

必要條件

  • 安裝最新版本的適當 CLI 擴充功能
  • 內部部署叢集必須能夠連線到 Azure。
  • 取得資源的資源組名 Cluster
  • 此程式會將金鑰集套用至所有執行中的裸機機器。
  • 新增的用戶必須是 Microsoft Entra 群組的一部分。 如需詳細資訊,請參閱 如何管理群組
  • 若要限制管理金鑰集的存取權,請建立自定義角色。 如需詳細資訊,請參閱 Azure 自定義角色。 在此實例中,新增或排除 的許可權 Microsoft.NetworkCloud/clusters/bmcKeySets。 選項有 /read/write/delete

注意

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

建立 BMC 金鑰集

命令 bmckeyset create 會為一組使用者建立叢集中裸機計算機的 SSH 存取權。

命令語法為:

az networkcloud cluster bmckeyset create \
  --name <BMC Keyset Name> \
  --extended-location name=<Extended Location ARM ID> \
    type="CustomLocation" \
  --location <Azure Region> \
  --azure-group-id <Azure AAD Group ID> \
  --expiration <Expiration Timestamp> \
  --jump-hosts-allowed <List of jump server IP addresses> \
  --privilege-level <"Administrator" or "ReadOnly"> \
  --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 <Resource Group Name>

建立自變數

  --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.
  --bmc-key-set-name --name -n                [Required] : The name of the BMC 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 BMCs. The limit is up to 1 year from creation.
                                                           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".
  --privilege-level                           [Required] : The access level allowed for the users
                                                           in this key set.  Allowed values:
                                                           "Administrator" or "ReadOnly".
  --resource-group -g                         [Required] : Name of 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.
  --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 bmckeyset create \
  --name "bmcKeySetName" \
  --extended-location name="/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName" \
    type="CustomLocation" \
  --location "location" \
  --azure-group-id "f110271b-XXXX-4163-9b99-214d91660f0e" \
  --expiration "2023-12-31T23:59:59.008Z" \
  --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"}},\
  {"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"}}]' \
  --tags key1="myvalue1" key2="myvalue2" \
  --cluster-name "clusterName" \
  --resource-group "resourceGroupName"

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

刪除 BMC 金鑰集

命令 bmckeyset delete 會移除使用者群組 BMC 的 SSH 存取權。 群組的所有成員都會失去叢集中任何 BMC 的 SSH 存取權。

命令語法為:

az networkcloud cluster bmckeyset delete \
  --name <BMC Keyset Name> \
  --cluster-name <Cluster Name> \
  --resource-group <Resource Group Name> \

刪除自變數

  --bmc-key-set-name --name -n                [Required] : The name of the BMC key set to be deleted.
  --cluster-name                              [Required] : The name of the cluster.
  --resource-group -g                         [Required] : Name of 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」 叢集中的 「bmcKeysetName」 機碼集群組。

az networkcloud cluster bmckeyset delete \
  --name "bmcKeySetName" \
  --cluster-name "clusterName" \
  --resource-group "resourceGroupName" \

更新 BMC 金鑰集

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

命令語法為:

az networkcloud cluster bmckeyset update \
  --name <BMC 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 <Resource Group Name>

更新自變數

  --bmc-key-set-name --name -n                [Required] : The name of the BMC 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 BMCs. 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:
                                                           "Administrator" or "ReadOnly".
  --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 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.

本範例會將兩個新使用者新增至 「bmcKeySetName」 群組,並變更群組的到期時間。

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

列出 BMC 金鑰集

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

命令語法為:

az networkcloud cluster bmckeyset list \
  --cluster-name <Cluster Name> \
  --resource-group <Resource Group Name>

列出自變數

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

顯示 BMC 金鑰集詳細資料

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

命令語法為:

az networkcloud cluster bmckeyset show \
  --cluster-name <Cluster Name> \
  --resource-group <Resource Group Name>

顯示自變數

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