2

I'm having an issue with the Shield plugin for Elasticsearch. I have installed elasticsearch so that it runs as a service, and I can see that it is running on port 9200.

If I enter curl http://localhost:9200 in my Mac terminal I get the correct elasticsearch output...

Recently I have been trying to upgrade from basic authentication to shield authentication. I installed shield and license using the following commands:

/usr/share/elasticsearch/bin/plugin install license/latest
/usr/share/elasticsearch/bin/plugin install shield/latest

This successfull installs shield and license plugins. They are contained within my /usr/share/elasticsearch/plugins directory on my Vagrant box.

So, now if I try to use curl -XGET http://localhost:9200 again, I get the following response:

{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"shield\""}}],"type":"security_exception","reason":"missing authentication token for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"shield\""}},"status":401}

This is good. I can not reach elasticsearch without proper authentication. So now I want to create a user to authenticate to elasticsearch. I use the command:

sudo ./esusers useradd testuser -p password -r admin

This creates a user 'testuser' with password 'password' with admin privileges.

I can verify that this user has been created using the following command:

sudo ./esusers list

This returns:

testuser : admin

So I now try to run the curl command again with this user:

curl -u testuser:password -XGET http://localhost:9200

But I get the same error message as before when I tried without the admin user.

What is the issue here? Why is my admin user not authenticating?

4

1 回答 1

2

您说您已验证用户是使用创建的,sudo ./esusers list但 curl 命令仍然失败。即使主目录是/usr/share/elasticsearch. 因此,esusers在目录中创建用户,/etc/elasticsearch/shield/但如果您使用的是自定义目录,则需要将它们复制到自定义目录。

我知道你已经以不同的方式解决了这个问题,但我正在回答这个问题,希望它在未来对其他人有所帮助。你能确认一下自定义目录吗?例如,在我的情况下,自定义目录是/data/elasticsearch,主目录是/usr/share/elasticsearch

于 2016-09-22T11:51:38.120 回答