# Snapshot using a s3 bucket and xpack security

**URL:** <https://discuss.elastic.co/t/snapshot-using-a-s3-bucket-and-xpack-security/195962>\
**Category:** Elasticsearch\
**Created:** [August 20, 2019, 3:01pm UTC](https://discuss.elastic.co/t/snapshot-using-a-s3-bucket-and-xpack-security/195962 "2019-08-20T15:01:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsandri](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jsandri](https://discuss.elastic.co/u/jsandri)\
**Post date:** [August 20, 2019, 3:01pm UTC](https://discuss.elastic.co/t/snapshot-using-a-s3-bucket-and-xpack-security/195962/1 "2019-08-20T15:01:00Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [August 21, 2019, 6:26am UTC](https://discuss.elastic.co/t/snapshot-using-a-s3-bucket-and-xpack-security/195962/2 "2019-08-21T06:26:23Z")

</div>

Hi,

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

```auto
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"
    }
}'

```

---

<div class="post-metadata">

**Author:** ![jsandri](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jsandri](https://discuss.elastic.co/u/jsandri)\
**Post date:** [August 22, 2019, 3:35am UTC](https://discuss.elastic.co/t/snapshot-using-a-s3-bucket-and-xpack-security/195962/3 "2019-08-22T03:35:38Z")

</div>

Thanks a lot it works!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 19, 2019, 3:35am UTC](https://discuss.elastic.co/t/snapshot-using-a-s3-bucket-and-xpack-security/195962/4 "2019-09-19T03:35:45Z")

</div>

Closed on September 19, 2019, 3:35am UTC

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