# Create user in elasticsearch

**URL:** <https://discuss.elastic.co/t/create-user-in-elasticsearch/182401>\
**Category:** Elasticsearch\
**Created:** [May 23, 2019, 10:33am UTC](https://discuss.elastic.co/t/create-user-in-elasticsearch/182401 "2019-05-23T10:33:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![safderali5](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@safderali5](https://discuss.elastic.co/u/safderali5)\
**Post date:** [May 23, 2019, 10:33am UTC](https://discuss.elastic.co/t/create-user-in-elasticsearch/182401/1 "2019-05-23T10:33:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 23, 2019, 12:49pm UTC](https://discuss.elastic.co/t/create-user-in-elasticsearch/182401/2 "2019-05-23T12:49:05Z")

</div>

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

```auto
---
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:

```auto
ELASTIC_VERSION=7.1.0
ELASTIC_SECURITY=true
ELASTIC_PASSWORD=changeme

```

And if the context of integration tests with Maven:

> <https://github.com/dadoonet/fscrawler/blob/c6fbca653db7dbcfa344f7de180e6c9f8bda6599/integration-tests/it-v7/pom.xml#L169-L201>

HTH

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [May 24, 2019, 2:16am UTC](https://discuss.elastic.co/t/create-user-in-elasticsearch/182401/3 "2019-05-24T02:16:11Z")

</div>

> [@safderali5](#):
>
> Can we automatically create new user and set passwords for default users(e.g kibana, logstash\_system, elasticsearch etc) during elasticsearch startup

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.

---

<div class="post-metadata">

**Author:** ![safderali5](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@safderali5](https://discuss.elastic.co/u/safderali5)\
**Post date:** [May 24, 2019, 6:33am UTC](https://discuss.elastic.co/t/create-user-in-elasticsearch/182401/4 "2019-05-24T06:33:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 21, 2019, 6:33am UTC](https://discuss.elastic.co/t/create-user-in-elasticsearch/182401/5 "2019-06-21T06:33:07Z")

</div>

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