Providing input to elasticsearch-keystore.bat programatically

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.

{
    "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.

Hi there :wave:

See the -x, —stdin option in the docs and the accompanying example: elasticsearch-keystore | Elasticsearch Guide [8.0] | Elastic

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.

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