使用密钥凭证连接到 AWS 中的 elasticsearch
Connect to elasticsearch in AWS using key credentials
我正在尝试使用我的 accessKey 和 secretKey post 使用 curl 向我在 AWS 中的 es 集群发出请求。我已通过 postman (details here) 成功完成此操作,您可以在其中指定 AWS 凭据,但我想使用 curl 来完成此操作。 Postman 可以为您自动生成您的 curl 请求,但我得到的只是错误。
这是生成的 curl 请求和响应
curl -X GET \
https://search-00000000000001.eu-west-1.es.amazonaws.com/_cat/indices \
-H 'Authorization: AWS4-HMAC-SHA256 Credential=11111111111111111111/20181119/eu-west-1/es/aws4_request, SignedHeaders=cache-control;content-type;host;postman-token;x-amz-date, Signature=11111111116401882398f46011f14fdb9d55e012a4fb912706d67c1111111111' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: search-00000000000001.eu-west-1.es.amazonaws.com' \
-H 'Postman-Token: 00000000-0000-4001-8006-9291e208a000' \
-H 'X-Amz-Date: 20181119T220000Z' \
-H 'cache-control: no-cache'
{"message":"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."}%
ID 已更改以保护无辜者。
我已经检查了所有密钥和区域,就像我说的那样,这可以通过 postman 进行。是否可以通过 curl 使用我的密钥访问此 AWS 服务?
这是一个相当长的兔子洞。感谢 Adam 的评论,使我朝着正确的方向前进。 link https://docs.aws.amazon.com/apigateway/api-reference/signing-requests/ 确实可以帮助您了解需要做什么。
我后来发现了一个遵循上述签名请求方法的脚本。它在 bash 中运行,虽然它不是为与 elasticsearch 请求一起使用而编写的,但它可以用于它们。
https://github.com/riboseinc/aws-authenticating-secgroup-scripts many thanks to https://www.ribose.com 把这个放在 github.
如果您的主机包含“:443”,请将其删除并重试。
这对我有用。
"My initial problem: If I access it with Postman using the same url, I get the same error, but removing the ‘:443/’, it works fine, so it’s nothing wrong with the key and secret I’m using."
我正在尝试使用我的 accessKey 和 secretKey post 使用 curl 向我在 AWS 中的 es 集群发出请求。我已通过 postman (details here) 成功完成此操作,您可以在其中指定 AWS 凭据,但我想使用 curl 来完成此操作。 Postman 可以为您自动生成您的 curl 请求,但我得到的只是错误。
这是生成的 curl 请求和响应
curl -X GET \
https://search-00000000000001.eu-west-1.es.amazonaws.com/_cat/indices \
-H 'Authorization: AWS4-HMAC-SHA256 Credential=11111111111111111111/20181119/eu-west-1/es/aws4_request, SignedHeaders=cache-control;content-type;host;postman-token;x-amz-date, Signature=11111111116401882398f46011f14fdb9d55e012a4fb912706d67c1111111111' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: search-00000000000001.eu-west-1.es.amazonaws.com' \
-H 'Postman-Token: 00000000-0000-4001-8006-9291e208a000' \
-H 'X-Amz-Date: 20181119T220000Z' \
-H 'cache-control: no-cache'
{"message":"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."}%
ID 已更改以保护无辜者。
我已经检查了所有密钥和区域,就像我说的那样,这可以通过 postman 进行。是否可以通过 curl 使用我的密钥访问此 AWS 服务?
这是一个相当长的兔子洞。感谢 Adam 的评论,使我朝着正确的方向前进。 link https://docs.aws.amazon.com/apigateway/api-reference/signing-requests/ 确实可以帮助您了解需要做什么。
我后来发现了一个遵循上述签名请求方法的脚本。它在 bash 中运行,虽然它不是为与 elasticsearch 请求一起使用而编写的,但它可以用于它们。
https://github.com/riboseinc/aws-authenticating-secgroup-scripts many thanks to https://www.ribose.com 把这个放在 github.
如果您的主机包含“:443”,请将其删除并重试。 这对我有用。
"My initial problem: If I access it with Postman using the same url, I get the same error, but removing the ‘:443/’, it works fine, so it’s nothing wrong with the key and secret I’m using."