Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Control in Elastic - missing authentication credentials for REST request

I am using Elastic 7.9.2 version and wanted to use security. so I ran :

bin/elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass ""

and then added

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p1

in config/elasticsearch.yaml

Now when I am running the ES by

 bin/elasticsearch

getting below error :

"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials
 for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-
8\""}}],"type":"security_exception","reason":"missing authentication credentials for REST 
request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-
8\""}},"status":401}root@ip-localhost:/var/log/elasticsearch

Can anyone please help!

like image 553
Tech Geek Avatar asked Nov 06 '22 04:11

Tech Geek


2 Answers

Just pass authentication credential with url like below

curl -X GET "http://localhost:9200" -u elastic:pass123
like image 193
Sheikh Wasiu Al Hasib Avatar answered Nov 11 '22 06:11

Sheikh Wasiu Al Hasib


I had security already enabled and user authentication working. Kibana loaded fine.

I have a 3 node cluster and stopped elasticsearch service on each node so I could add transport ssl. After enabling xpack.security.transport.ssl.enabled and keystore and truststore settings, I got the same ""missing authentication credentials for REST request" error in Kibana. Turns out the error was because I only had one node running and needed a minimum of two. After enabling transport ssl on another node and starting it, kibana worked again.

like image 22
Philip Holly Avatar answered Nov 11 '22 08:11

Philip Holly