Create user in elasticsearch

Can we automatically create new user and set passwords for default users(e.g kibana, logstash_system, elasticsearch etc) during elasticsearch startup.
i.e setting it up in elasticsearch configuration or providing that data through some config file?

I am referring to elasticsearch version 6.8.0 or 7.1.0, where xpack security features are included in basic license.

Here is I'm setting that with docker compose ( docker-compose.yml):

---
version: '3'
services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:$ELASTIC_VERSION
    environment:
      - bootstrap.memory_lock=true
      - discovery.type=single-node
      - cluster.name=elasticsearch
      - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
      - cluster.routing.allocation.disk.threshold_enabled=false
      - ELASTIC_PASSWORD=$ELASTIC_PASSWORD
      - xpack.security.enabled=$ELASTIC_SECURITY
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200:9200
      - 9300:9300
    networks: ['stack']

  kibana:
    image: docker.elastic.co/kibana/kibana:$ELASTIC_VERSION
    environment:
      - ELASTICSEARCH_USERNAME=elastic
      - ELASTICSEARCH_PASSWORD=$ELASTIC_PASSWORD
    ports: ['5601:5601']
    networks: ['stack']
    links: ['elasticsearch']
    depends_on: ['elasticsearch']

networks:
  stack: {}

.env file is:

ELASTIC_VERSION=7.1.0
ELASTIC_SECURITY=true
ELASTIC_PASSWORD=changeme

And if the context of integration tests with Maven:

HTH

No you need to do this yourself (though you can automate it).
We don't provide a way to do that sort of initialisation on startup.

Thanks, elasticsearch official docker file helped to solve my problem. setting ELASTIC_PASSWORD is what i was looking for.

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