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>
demandé il y a un an14605 vues
3 réponses
3
Réponse acceptée

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
EXPERT
kentrad
répondu il y a un an
profile picture
EXPERT
vérifié il y a un mois
0
profile picture
EXPERT
répondu il y a un an
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
répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions