Here is the official doc for setting up security for Elasticsearch
step 1: cd /usr/share/elasticsearch/
step 2:
sudo bin/elasticsearch-setup-passwords auto
or
sudo bin/elasticsearch-setup-passwords interactive
auto - Uses randomly generated passwords interactive - Uses passwords entered by a user
The above commands can help you to setup password
or
./elasticsearch-reset-password -i -u elastic
ref: https://stackoverflow.com/questions/59644348/how-to-setup-password-for-elasticsearch-users