I am getting 401 - Unauthorized when I hit meta-data API

2

Hello Team,

I am new to AWS, I have created an EC2 instance and trying to use the meta-data API from the EC2 instance and getting the below error. I checked the server time, and rebooted the instance as suggested in the forums. Not sure What I am doing wrong. Any help would be appreciated thanks!

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>401 - Unauthorized</title>
 </head>
 <body>
  <h1>401 - Unauthorized</h1>
 </body>
</html>
已提問 1 年前檢視次數 14600 次
3 個答案
3
已接受的答案

Could be that your instance is using V2 of the meta data service. Take a look here to see how to obtain a token and pass it with the query.

Add defense in depth against open firewalls, reverse proxies, and SSRF vulnerabilities with enhancements to the EC2 Instance Metadata Service.

profile pictureAWS
專家
kentrad
已回答 1 年前
profile picture
專家
已審閱 1 個月前
0
profile picture
專家
已回答 1 年前
0

The following section provides a short explanation for each response: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html#instance-metadata-returns

For example:

  • 401 - Unauthorized – The GET request uses an invalid token. The recommended action is to generate a new token.
AWS
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南