Snapshot using a s3 bucket and xpack security

Hi all,
I deploy an ELK version 7.2.0 on AWS and when I run this command

curl -XPUT "http://localhost:9200/_snapshot/s3_backups" -H "Content-Type: application/json" -d ' {
  "type": "s3", 
    "settings": { 
      "bucket": "'my_bucket'", 
      "base_path": "'my_path'",
      "region": "ap-southeast-1"
    }
}'

in the terminal I encounter the following error:

{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/_snapshot/s3_backups]","header":{"WWW-Authenticate":"Basic realm="security" charset="UTF-8""}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/_snapshot/s3_backups]","header":{"WWW-Authenticate":"Basic realm="security" charset="UTF-8""}},"status":401}[centos@ip-X-X-X-X scripts]

This error doesn't appear if I run this command directly from the Kibana Console. I also noticed that this error didn't appear when I don't use xpack security in other words when the next line is not in elasticsearch.yml.

xpack.security.enabled: true

I concluded I need to add a field or parameter somewhere in the curl command perhaps something such as a username and password but the question is where?

Thanks a lot for your help if you need more explanations let me know :slight_smile:

Hi,

See https://curl.haxx.se/docs/manpage.html for how to pass basic authentication credentials with Curl. Use I.e.

curl -XPUT -u username:password "http://localhost:9200/_snapshot/s3_backups" -H "Content-Type: application/json" -d ' {
  "type": "s3", 
    "settings": { 
      "bucket": "'my_bucket'", 
      "base_path": "'my_path'",
      "region": "ap-southeast-1"
    }
}'

Thanks a lot it works!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.