Security Exception while trying to open all indices

security

(Prince) #1

Hi,

While trying snapshot and restore, unfortunately I closed all the indices after taking snapshot. Now I am trying to open all the indices but getting a security exception.

$ curl --cacert 'certificate_path' -u "elastic:xxxxxxxxx" -XPOST "https://node_name:9200/*/_open?pretty"
{
"error" : {
"root_cause" : [
{
"type" : "security_exception",
"reason" : "failed to authenticate user [elastic]",
"header" : {
"WWW-Authenticate" : "Basic realm="security" charset="UTF-8""
}
}
],
"type" : "security_exception",
"reason" : "failed to authenticate user [elastic]",
"header" : {
"WWW-Authenticate" : "Basic realm="security" charset="UTF-8""
}
},
"status" : 401
}

How do i open all the indices now?


(Tim Vernum) #2

Did you close the .security index?
Don't do that.

You'll need to create an alternative superuser in the file realm.

Assuming you haven't modified the default realm setup, then you just need to run this on one of your nodes.

bin/x-pack/users useradd admin -r superuser -p changeme
sleep 5
curl --cacert 'certificate_path' -u "admin:changeme"  -XPOST "https://localhost:9200/.security*/_open"

That should open the security index again, and you can then work with the elastic user as normal.
At the end, remove the admin user with:

bin/x-pack/users userdel admin

(Prince) #3

Thanks Tim, Working fine...