# Providing input to elasticsearch-keystore.bat programatically

**URL:** <https://discuss.elastic.co/t/providing-input-to-elasticsearch-keystore-bat-programatically/297670>\
**Category:** Elasticsearch\
**Created:** [February 19, 2022, 6:05pm UTC](https://discuss.elastic.co/t/providing-input-to-elasticsearch-keystore-bat-programatically/297670 "2022-02-19T18:05:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Newbie111985](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/newbie111985/32/17561_2.png) [@Newbie111985](https://discuss.elastic.co/u/Newbie111985)\
**Post date:** [February 19, 2022, 6:05pm UTC](https://discuss.elastic.co/t/providing-input-to-elasticsearch-keystore-bat-programatically/297670/1 "2022-02-19T18:05:34Z")

</div>

Hi,  
I need to add few settings to Elasticsearch keystore in windows using `elasticsearch-keystore.bat` file. Hence I tried the following from the windows command prompt:  
`echo "mypwd" | D:\Elasticsearch-7.17.0\bin\elasticsearch-keystore.bat add bootstrap.password --force`  
This didn't prompt me to input the password but after starting the Elasticsearch server, getting below error when I am trying to use the password mentioned above.

```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\""
                }
            }
        ],
        "type": "security_exception",
        "reason": "unable to authenticate user [elastic] for REST request [/]",
        "header": {
            "WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
        }
    },
    "status": 401
}

```

Hence is there a way to provide input to `elasticsearch-keystore.bat` programatically? (instead of inputting from the command prompt). Thanks in advance.

P.S. This problem is not seen when I manually input the password using the command prompt.

---

<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:** [February 20, 2022, 8:02pm UTC](https://discuss.elastic.co/t/providing-input-to-elasticsearch-keystore-bat-programatically/297670/2 "2022-02-20T20:02:18Z")

</div>

Hi there 👋

See the `-x`, `—stdin` option in the docs and the accompanying example: [elasticsearch-keystore | Elasticsearch Guide [8.0] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/elasticsearch-keystore.html#add-string-to-keystore)

---

<div class="post-metadata">

**Author:** ![Newbie111985](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/newbie111985/32/17561_2.png) [@Newbie111985](https://discuss.elastic.co/u/Newbie111985)\
**Post date:** [February 21, 2022, 4:08am UTC](https://discuss.elastic.co/t/providing-input-to-elasticsearch-keystore-bat-programatically/297670/3 "2022-02-21T04:08:41Z")

</div>

Thanks for your reply.  
I did try this and it doesn't seem to work as well. Please note that I am facing this problem only in Windows. For eg. Below command works fine in Linux:  
`echo "mypwd" | /Elasticsearch-7.17.0/bin/elasticsearch-keystore add bootstrap.password --force`  
Hence I would like to know how to get similar thing working in Windows. Thanks.

---

<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:** [March 21, 2022, 4:08am UTC](https://discuss.elastic.co/t/providing-input-to-elasticsearch-keystore-bat-programatically/297670/4 "2022-03-21T04:08:57Z")

</div>

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