Skip to content

Instantly share code, notes, and snippets.

@alsunseri
Created October 26, 2023 03:57
Show Gist options
  • Save alsunseri/9682bd3c8ff2cf6ea8fdc1d2b286afe6 to your computer and use it in GitHub Desktop.
Save alsunseri/9682bd3c8ff2cf6ea8fdc1d2b286afe6 to your computer and use it in GitHub Desktop.
How to login to Kibana/elastic if you forget the passwords set via elasticsearch-setup-passwords

I ran elasticsearch-setup-passwords to add "security" to my little ELK stack. But 2 months later I could not log in, I did not write the passwords down -
and the username and password sets were not stored in the configs like i thought they were .

Instead of turning security off or starting over I found a better way to "recover" my kibana login credentials.

Once I did this I was able to log into "elastic"/Kibana and get back to searching through logs.

This is what I did as root:

# /usr/share/elasticsearch/bin/elasticsearch-users useradd alsunseri 
   ( enter a new password and enter it a again to confirm )
# /usr/share/elasticsearch/bin/elasticsearch-users roles alsunseri --add  kibana_admin 
# /usr/share/elasticsearch/bin/elasticsearch-users roles alsunseri --add  kibana_system
# /usr/share/elasticsearch/bin/elasticsearch-users roles alsunseri --add  superuser

Then I was able to login to kibana/elastic again on port 5061

Later I can remove the superuser role and only grant what is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment