# Security Exception while trying to open all indices

**URL:** https://discuss.elastic.co/t/security-exception-while-trying-to-open-all-indices/157272
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [November 19, 2018, 6:07am UTC](https://discuss.elastic.co/t/security-exception-while-trying-to-open-all-indices/157272 "2018-11-19T06:07:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Elango-mas](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@Elango-mas](https://discuss.elastic.co/u/Elango-mas)
#### Post date: [November 19, 2018, 6:07am UTC](https://discuss.elastic.co/t/security-exception-while-trying-to-open-all-indices/157272/1 "2018-11-19T06:07:04Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)
#### Post date: [November 19, 2018, 6:43am UTC](https://discuss.elastic.co/t/security-exception-while-trying-to-open-all-indices/157272/2 "2018-11-19T06:43:04Z")

</div>

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.

```auto
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:

```auto
bin/x-pack/users userdel admin

```

---

<div class="post-metadata">

### Author: ![Elango-mas](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@Elango-mas](https://discuss.elastic.co/u/Elango-mas)
#### Post date: [November 29, 2018, 9:40am UTC](https://discuss.elastic.co/t/security-exception-while-trying-to-open-all-indices/157272/3 "2018-11-29T09:40:56Z")

</div>

Thanks Tim, Working fine...

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 27, 2018, 9:40am UTC](https://discuss.elastic.co/t/security-exception-while-trying-to-open-all-indices/157272/4 "2018-12-27T09:40:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
