# 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:** 3

<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:05am UTC](https://discuss.elastic.co/t/automate-elasticsearch-reset-password-in-bash-script/317429/3 "2022-10-26T02:05:12Z")

</div>

I am automating the installation and configuration of elasticsearch and kibana. Following the post from 2018 - [How to set passwords for built-in users in batch mode?](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/6) - I should be able to automate ` elasticsearch-reset-password` by running the following commands:

```auto
cd /usr/share/elasticsearch/bin
 printf "elk-demo" | elasticsearch-keystore add -x
sudo curl -uelastic -XPUT -H 'Content-Type: application/json' 'http://localhost:9200/_xpack/security/user/kibana/_password' -d '{ "password":new-kibana-password" }'

```

but when I did this, I got the message:  
`elasticsearch-keystore: command not found`

I also tried:  
`sudo printf "elk-demo" | bin/elasticsearch-reset-password -i -b`  
but I got the error:

```auto
Enter password for [elastic]: Re-enter password for [elastic]: 
ERROR: unable to read from standard input; is standard input open and a tty attached?

```

What i am trying to achieve is reset the password through a script without any user interaction or request to type in password or re-enter password. There are no helpful elasticsearch logs. Just long list of warnings saying:

```auto
received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=

```

---

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