'How to get a token from a ElasticSearch server?

I am trying to connect kibana to an elasticsearch server, where the username is "elastic", which means I cannot use the user and password to connect to the server, I have to use a token.

I tried to run command curl -H "Authorization: Bearer dGhpcyBpcyBub3Qx5...F0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==" http://localhost:9200

However, this doesn't work, the error message says I did not provide enough credentials, which makes sense since this server is password protected.

And then I tried to run the command curl -H "Authorization: Bearer dGhpcyBpcyBub3Qx5...F0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==" http://localhost:9200 -u elastic:password, but it still doesn't work and tells me the command syntax is wrong.

What should I do?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source