LoginSignup
46
22

More than 3 years have passed since last update.

AWS CLIでSignatureDoesNotMatchになった

Last updated at Posted at 2019-07-21

公式の Issue に顛末や対応が載ったので追記します(2020/07/11)

SignatureDoesNotMatch error
https://github.com/aws/aws-cli/issues/602#issuecomment-648952330

  • OSとシークレットアクセスキーに含まれた特殊文字の組み合わせによっては、SignatureDoesNotMatchに遭遇する
  • 最も手軽な対応は、AWS公式のトラブルシュートにも追記された通り、秘密鍵を再作成して特殊文字が含まれないものを使用する
  • このエラーについて情報提供してくれる場合はGithubにIssueテンプレートが用意されているのでそれを使ってね

追記ここまで。ここまで読めば問題無いと思います。

これは何?

AWS CLIでハマったので、対応をメモ。原因は推測。

エラーの概要

この例では、IAMユーザーをリスト表示しようとしてaws iam list-usersでエラー。
他のコマンドでも、おおむね同じようにエラー。

PS C:\dev\terraform> aws iam list-users
An error occurred (SignatureDoesNotMatch) when calling the ListUsers operation: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.

要するに「署名が合わないからシークレットアクセスキーを確認しろ」と言われている。

tl;dr

  • C:\Users\$USER\.awsconfigcredentialsを一度削除した
  • アクセスキーを新しくした
  • キーに特殊文字が入っていると、NGになることがある?

環境

  • Win10Pro 64bit
  • PowerShellからAWS CLI使用
  • aws-cli/1.16.201 Python/3.6.0 Windows/10 botocore/1.12.191

エラーになるまでにやったこと

  1. 新しいIAMユーザーを作成し、アクセスキーを発行した
  2. aws configureコマンドでアクセスキーなどの情報を設定
  3. AWS CLIのコマンド発行すると、エラー

調べたこと

特殊文字?

同じようなエラーについてのissuesを見つけた。
シークレットアクセスキーに特殊文字が入っているとうまくいかない場合があるという話が5年も続いている。

私は先頭が=+/も含むシークレットアクセスキーを使っていてSignatureDoesNotMatchになったが、キーの再作成後は正常動いた。

issuesから一部のコメント。

I can confirm that recreating my access keys until I got one without special characters in it, worked. What a ridiculous bug, wow.
Seeing as this is such a long running issue, would it not be intelligent to update the error messaging to give users a link to a potential fix, like rebuilding your keys? Instead of something which makes out that the issue is far more complex than "yeah we error out when your keys have special chars in them, sorry!".

特殊文字が含まれていないアクセスキーを取得するまでアクセスキーを再作成してもうまくいったことを確認できます。 なんてばかげたバグ、すごい。
これは非常に長期にわたる問題であるため、エラーメッセージを更新してユーザーにキーの再構築などの潜在的な修正へのリンクを提供するのは賢明ではないでしょうか。 問題が「あなたの鍵に特別な文字が含まれているとエラーになる」というよりもはるかに複雑であることが判明したものではなく、残念です。

環境にもよる?

Windows10では起きた、Macでは同じキーを使っても起きなかった、と言ってる人も。

Got the same error today, currently using Windows 10. However, when I use the same access key on another laptop (mac), it works fine for me. Then I tried the access key within WSL, which is also fine. Not sure the reason, and there is no special character in the aws key.

現在Windows 10を使用している、今日も同じエラーが発生しました。ただし、別のラップトップ(Mac)で同じアクセスキーを使用すると、問題なく動作します。それから私はWSL内でアクセスキーを試しましたが、これも問題ありません。その理由はわかりません。awsキーに特殊文字はありません。

おわり

あんまり詳しくないけどエンコードで勝手に文字追加される類の話なのかなあ。つかれた。

46
22
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
46
22