Search code examples
elasticsearchelasticsearch-x-pack

Change default password in elasticsearch using .yml file


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"

Solution

  • 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.