Fix AWS CLI 2 SignatureDoesNotMatch Error - Signature we calculated does not match

AWS SignatureDoesNotMatch CLI Error
% aws s3 ls

A client error (SignatureDoesNotMatch) occurred when calling 
the ListBuckets operation: The request signature we calculated
does not match the signature you provided. 

Check your key and signing method.

While trying to run the aws s3 ls command to list all buckets using the aws cli 2, I ran into the above error message that said the request signature calculated did not match with the signature you provided.

I had set the AWS_SECRET_ACCESS_KEY and the AWS_ACCESS_KEY_ID which I re-check by doing a cat,

% cat ~/.aws/credentials

aws_access_key_id = AKIAYXXXXXXXXXXXXXXX
aws_secret_access_key = AKIAYXXXXXXXXXXXXXXX
Reason in my case:

As you can see I had set both the access and secret keys as the same, this caused the secret key to be wrong causing SignatureDoesNotMatch.

Some reasons for the SignatureDoesNotMatch AWS CLI Error:
  • Make sure that the secret keys are set correctly and valid.
  • Make sure the secret key have not expired.
  • Make sure you device time is up-to-date
  • Make sure you copy-pasted the secret key correctly without leading/trailing spaces or typos.
Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.