# How to achieve data Encryption in elasticsearch

**URL:** https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [August 12, 2019, 6:30am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793 "2019-08-12T06:30:22Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)
#### Post date: [August 12, 2019, 6:30am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/1 "2019-08-12T06:30:22Z")

</div>

Hi,

I need to encrypt the data before indexing into elastic search so that actual data is protected and while searching it should produce the proper results. Please let me know how this can be achieved in elasticsearch.

And one more question is the data stored in servers are encrypted ?  
Thanks!

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 12, 2019, 7:08am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/2 "2019-08-12T07:08:48Z")

</div>

You can encrypt in transit and at rest, but encrypting the data stored in the documents will limit search functionality quite severely.

---

<div class="post-metadata">

### Author: ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)
#### Post date: [August 12, 2019, 7:11am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/3 "2019-08-12T07:11:18Z")

</div>

Thanks for you reply @Christian_Dahlqvist.

Can you please tell me how to do it.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 12, 2019, 7:13am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/4 "2019-08-12T07:13:27Z")

</div>

To do what? Encryption in transit is done by enabling security and encryption at rest at the OS level e.g. using dm-crypt.

---

<div class="post-metadata">

### Author: ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)
#### Post date: [August 12, 2019, 7:24am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/5 "2019-08-12T07:24:35Z")

</div>

I want to encrypt all the data that is stored in an elastic search index. So can you please tell how to do that with dm-crypt or is there any other way.

If we encrypt the data can you please tell how to provide search features ?  
Thanks!

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 12, 2019, 8:38am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/6 "2019-08-12T08:38:21Z")

</div>

Please look at the dm-crypt documentation. It encrypts the file system, not data in indices so does not affect search.

---

<div class="post-metadata">

### Author: ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)
#### Post date: [August 12, 2019, 9:06am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/7 "2019-08-12T09:06:05Z")

</div>

Thanks for your reply.

I have one doubt - If we encrypt the file system when we access elastic index through [https://localhost:9200/](https://localhost:9200/) the data in the index will be encrypted or not. Because i want to encrypt the data so that if anyone tries to access my index through [https://localhost:9200/](https://localhost:9200/) they should not see actual data.

One more doubt - FIle system is nothing but where we store the elastic data which we give in path.data property in elastic yml configuration . Correct right ?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 12, 2019, 9:25am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/8 "2019-08-12T09:25:43Z")

</div>

If you want to encrypt the data in the documents you will basically only be able to perform exact match searches using encrypted strings. This will severely limit search functionality.

---

<div class="post-metadata">

### Author: ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)
#### Post date: [August 12, 2019, 9:51am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/9 "2019-08-12T09:51:46Z")

</div>

Is there any other way to encrypt the data stored in the index ?

What i thought is encrypting the data before indexing into elastic. But i dint get a solution on how to search on actual data if the encrypted data is stored in the index.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 12, 2019, 9:58am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/10 "2019-08-12T09:58:24Z")

</div>

As far as I know that is not possible.

---

<div class="post-metadata">

### Author: ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)
#### Post date: [August 12, 2019, 10:08am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/11 "2019-08-12T10:08:01Z")

</div>

okay thank you @Christian_Dahlqvist

---

<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: [September 9, 2019, 10:08am UTC](https://discuss.elastic.co/t/how-to-achieve-data-encryption-in-elasticsearch/194793/12 "2019-09-09T10:08:05Z")

</div>

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