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"
Glen Thompson
  • 9,071
  • 4
  • 54
  • 50

2 Answers2

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.

Andrei Stefan
  • 51,654
  • 6
  • 98
  • 89
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>

Glen Thompson
  • 9,071
  • 4
  • 54
  • 50