最近更新时间:2023.06.01 17:44:28
首次发布时间:2022.07.01 09:19:39
实例元数据包含了云服务器在云平台的基本信息,本文介绍如何查看实例元数据。
实例元数据只能从实例内部访问,数据并未被加密保护,可访问实例的人员均可查看其元数据。如果元数据中包含了敏感信息,您应当采取适当的措施来保护敏感数据,比如限制访问范围、加密等。
您可以通过 cURL 工具或是 HTTP 的 GET 请求来访问实例元数据,其格式为http://100.96.0.96/latest/[metadata]
。
请将其中的[metadata]
替换为具体的实例元数据项,更多信息,请参见实例元数据项。
下文以查看实例ID为例,为您介绍如何查看实例元数据,更多示例请参见查看元数据示例。
curl http://100.96.0.96/latest/instance_id
以使用cURL工具为例,在Linux实例中查看实例元数据的Shell命令示例如下所示:
curl http://100.96.0.96/latest
curl http://100.96.0.96/latest/instance_id
curl http://100.96.0.96/latest/network/interfaces/macs/$mac/primary_ip_address
curl http://100.96.0.96/latest/payment/charge_type
以使用Invoke-RestMethod工具为例,在Windows实例中查看实例元数据的PowerShell命令示例如下所示:
Invoke-RestMethod http://100.96.0.96/latest
Invoke-RestMethod http://100.96.0.96/latest/instance_id
Invoke-RestMethod http://100.96.0.96/latest/network/interfaces/macs/$mac/primary_ip_address
Invoke-RestMethod http://100.96.0.96/latest/payment/charge_type