# Automate Elasticsearch-reset-password in bash script

**URL:** <https://discuss.elastic.co/t/automate-elasticsearch-reset-password-in-bash-script/317429>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [October 25, 2022, 4:58pm UTC](https://discuss.elastic.co/t/automate-elasticsearch-reset-password-in-bash-script/317429 "2022-10-25T16:58:17Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Chma](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@Chma](https://discuss.elastic.co/u/Chma)\
**Post date:** [October 26, 2022, 2:33am UTC](https://discuss.elastic.co/t/automate-elasticsearch-reset-password-in-bash-script/317429/5 "2022-10-26T02:33:29Z")

</div>

This worked, thanks. But when i test that my elasticsearch is running, I get authentication error.

`sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200`  
When I am asked to `Enter host password for user 'elastic':` I enter the `elk-demo` password, but I get the below error message:

```auto
{"error":{"root_cause":[{"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}}],"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}},"status":401}root@ip-10-0-15-147:/usr/share/elasticsearch# 

```

Perhaps, I am missing something?

---

_[View the full topic](https://discuss.elastic.co/t/automate-elasticsearch-reset-password-in-bash-script/317429)._
