0

If I have an elasticsearch.yml config file is it possible to change the default password? What do I add in my .yml file to do that? Right now its changeme.

I am using Elasticsearch 5.6.4

My .yml file

cluster.name: "docker-cluster"
network.host: "0.0.0.0"

http.cors.enabled : true
http.cors.allow-origin : "*"
http.cors.allow-methods : "OPTIONS, HEAD, GET, POST, PUT, DELETE"
http.cors.allow-headers : "X-Requested-With, X-Auth-Token, Content-Type, Content-Length, Authorization"
3
  • Which version? In 6.x there is no default password anymore.
    – dadoonet
    Commented Feb 11, 2018 at 5:34
  • 5.6.4 - for 6.x is there no basic auth? Commented Feb 11, 2018 at 5:39
  • 1
    There is but no default password anymore. You need to run setup-passwords from the CLI in 6.x
    – dadoonet
    Commented Feb 11, 2018 at 8:18

2 Answers 2

4

You can change the password via the API, like this:

POST _xpack/security/user/elastic/_password
{
  "password": "whatever"
}

Or, in case you forgot it or similar: https://discuss.elastic.co/t/i-lost-the-password-that-has-been-changed/91867/2

But you cannot do anything similar to the elasticsearch.yml file.

3

Andrei answer works but can be problematic as the instance has to be running and you have to already be authenticated.

The following works for 6.7 and above and is more what I was looking for as a solution to boot elasticsearch with a custom password.

echo "<boot_password>" | bin/elasticsearch-keystore add -xf bootstrap.password

So my dockerfile looks like this

FROM docker.elastic.co/elasticsearch/elasticsearch:6.7.1

RUN echo "<boot_password>" | bin/elasticsearch-keystore add -xf bootstrap.password

COPY ./config/elasticsearch.yml /usr/share/elasticsearch/config/elasticsearch.yml

Now you can connect using

username: elastic

password: <boot_password>

Not the answer you're looking for? Browse other questions tagged or ask your own question.