你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

使用 az networkcloud cluster baremetalmachinekeyset

注意

请注意,使用 Azure 的所有其他故障排除选项已用尽时,在紧急情况下使用此过程。 对这些裸机的 SSH 访问仅限于通过此方法从指定的跳转主机列表管理的用户。

在极少数情况下,用户需要调查和解决裸机问题,所有其他方法都已通过 Azure 耗尽。 Azure 操作员 Nexus 提供 az networkcloud cluster baremetalmachinekeyset 命令,以便用户可以管理对这些裸机的 SSH 访问。 在密钥集创建时,通过交叉引用为用户提供的用户主体名称,根据提供的 Microsoft Entra ID,针对 Microsoft Entra ID --azure-group-id <Entra Group ID>验证用户是否具有适当的授权。

如果用户的用户主体名称不是提供组的成员,则用户的状态设置为“无效”,其状态消息将显示“无效,因为 userPrincipal 不是 AAD 组的成员”。如果 Azure 组 ID 无效,则密钥集中的每个用户的状态将设置为“无效”,其状态消息将显示“AAD 组不存在”。无效的用户保留在密钥集中,但不会为其密钥启用 SSH 访问。

注意

目前有一个过渡期,其中指定用户主体名称是可选的。 在将来的版本中,它将成为强制性的,将为所有用户强制实施 Microsoft Entra ID 验证。 建议用户在过渡期结束(计划于 2024 年 7 月)之前将用户主体名称添加到其密钥集,以避免密钥集失效。 请注意,如果将任何用户主体名称添加到密钥集中,即使未为所有用户添加这些名称,Microsoft Entra ID 验证也会启用,如果指定的组 ID 无效,这将导致整个密钥集失效。

该命令运行时,它会在群集中具有活动 Kubernetes 节点的每个裸机计算机上执行。 有一个对帐过程会定期运行,该进程会在原始命令时不可用的任何裸机计算机上重试该命令。 此外,任何通过 az networkcloud baremetalmachine actionreimage 或命令返回群集的 az networkcloud baremetalmachine actionreplace 裸机计算机(请参阅 BareMetal 函数)都会发送一个信号,导致任何活动键集在返回到群集后立即发送到计算机。 多个命令按接收的顺序执行。

组中的用户数没有限制。

注意

跳转主机 IP 地址的说明

  • 密钥集创建/更新过程将跳转主机 IP 地址添加到群集中每台计算机的 IP 表中。 这会限制仅允许从这些跳转主机进行 SSH 访问。
  • 请务必为跳转主机指定面向群集的 IP 地址。 这些 IP 地址可能与用于访问跳转主机的公共 IP 地址不同。
  • 添加后,用户可以从任何指定的跳转主机 IP(包括在另一个裸机密钥集组中定义的跳转主机 IP)访问裸机计算机。
  • 添加第一个裸机机密钥集时,现有 SSH 访问将保持不变。 但是,密钥集命令限制现有用户的 SSH 访问密钥集命令中指定的跳转主机 IP。

先决条件

  • 安装最新版本的 相应 CLI 扩展
  • 本地群集必须连接到 Azure。
  • 获取资源的 Cluster 资源组名称。
  • 此过程将密钥集应用于所有正在运行的裸机计算机。
  • 添加的用户必须是 Microsoft Entra 组的一部分。 有关详细信息,请参阅 “如何管理组”。
  • 若要限制管理密钥集的访问,请创建自定义角色。 有关详细信息,请参阅 Azure 自定义角色。 在此实例中,添加或排除权限 Microsoft.NetworkCloud/clusters/bareMetalMachineKeySets。 选项为 /read/write/delete

注意

通过本文所述的命令创建、修改或删除裸机访问时,后台进程会将这些更改传递到计算机。 此过程在操作员 Nexus 软件升级期间暂停。 如果已知正在进行升级,则可以将 --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 <Resource Group>

创建参数

  --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. 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 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/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName" \
    type="CustomLocation" \
  --location "location" \
  --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 "resourceGroupName"

有关创建 --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 <Resource Group Name>

删除参数

    --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 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 "resourceGroupName"

更新裸机密钥集

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 <Resource Group>

更新参数

  --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. 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 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 "resourceGroupName"

列出裸机密钥集

baremetalmachinekeyset list 命令允许用户查看群集中的现有密钥集组。

命令语法为:

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

列出参数

  --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>`.

显示裸机密钥集详细信息

baremetalmachinekeyset show 命令允许用户查看群集中现有密钥集组的详细信息。

命令语法为:

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

显示参数

  --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 resource group. You can
                                                           configure the default group using `az
                                                           configure --defaults group=<name>`.