# Unable to add key-value pair to keystore from command-line

**URL:** <https://discuss.elastic.co/t/unable-to-add-key-value-pair-to-keystore-from-command-line/224941>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [March 25, 2020, 5:21am UTC](https://discuss.elastic.co/t/unable-to-add-key-value-pair-to-keystore-from-command-line/224941 "2020-03-25T05:21:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandeepkanabar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeepkanabar/32/79399_2.png) [@sandeepkanabar](https://discuss.elastic.co/u/sandeepkanabar)\
**Post date:** [March 25, 2020, 5:21am UTC](https://discuss.elastic.co/t/unable-to-add-key-value-pair-to-keystore-from-command-line/224941/1 "2020-03-25T05:21:34Z")

</div>

In ES `6.8`:

I'm unable to add a key-value pair from command-line using `keystore`:

`/usr/share/elasticsearch/bin/elasticsearch-keystore add -E "foo=bar"`

`ERROR: The setting name can not be null`.

What could I be missing? I'm able to add `/usr/share/elasticsearch/bin/elasticsearch-keystore add foo` though and it prompts for the value.

---

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [March 26, 2020, 6:07am UTC](https://discuss.elastic.co/t/unable-to-add-key-value-pair-to-keystore-from-command-line/224941/2 "2020-03-26T06:07:03Z")

</div>

Hi there @sandeepkanabar,

`-E` is available in all `elasticsearch-x` CLI tools and is for configuring settings for the environment such as system properties. This is not specific to `elasticsearch-keystore` and cannot be used to add/set keystore settings.

```auto
bin/elasticsearch-keystore add foo 

```

_is_ the proper way to add setting the`foo`setting to your keystore.

If you don't want to be prompted, then you can use the `--stdin` option and `cat` a file or `echo` a string and pipe that into the `bin/elasticsearch-keystore` command, see more in [our docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/elasticsearch-keystore.html)

---

<div class="post-metadata">

**Author:** ![sandeepkanabar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeepkanabar/32/79399_2.png) [@sandeepkanabar](https://discuss.elastic.co/u/sandeepkanabar)\
**Post date:** [March 26, 2020, 11:40am UTC](https://discuss.elastic.co/t/unable-to-add-key-value-pair-to-keystore-from-command-line/224941/3 "2020-03-26T11:40:05Z")

</div>

Yeah thanks. I made use of the `echo foo-string | bin/elasticsearch-keystore` and got it working. I only asked about this because if you run the command `bin/elasticsearch-keystore add -h` then the very first option that appears is `-E`.

```auto
[root@foohost ~]# /usr/share/elasticsearch/bin/elasticsearch-keystore add -h
Add a string setting to the keystore

Non-option arguments:
setting name

Option Description
------ -----------
-E <KeyValuePair> Configure a setting
-f, --force Overwrite existing setting without prompting
-h, --help show help
-s, --silent show minimal output
-v, --verbose show verbose output
-x, --stdin Read setting value from stdin

```

---

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [March 26, 2020, 11:56am UTC](https://discuss.elastic.co/t/unable-to-add-key-value-pair-to-keystore-from-command-line/224941/4 "2020-03-26T11:56:53Z")

</div>

> [@sandeepkanabar](#):
>
> I only asked about this because if you run the command `bin/elasticsearch-keystore add -h` then the very first option that appears is `-E` .

Yeap, and as I mentioned above

> [@ikakavas](#):
>
> `-E` is available in all `elasticsearch-x` CLI tools and is for configuring settings for the environment such as system properties. This is not specific to `elasticsearch-keystore` and cannot be used to add/set keystore settings.

I get that both things are settings and this might get confusing for users. I'll follow up and see if we can change the -E message to something also generic which doesn't clash semantically with `elasticsearch-x` tools.

Thanks for the feedback

---

<div class="post-metadata">

**Author:** ![sandeepkanabar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeepkanabar/32/79399_2.png) [@sandeepkanabar](https://discuss.elastic.co/u/sandeepkanabar)\
**Post date:** [March 30, 2020, 11:34am UTC](https://discuss.elastic.co/t/unable-to-add-key-value-pair-to-keystore-from-command-line/224941/5 "2020-03-30T11:34:14Z")

</div>

Thank you very much 👍.

---

<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:** [April 27, 2020, 11:34am UTC](https://discuss.elastic.co/t/unable-to-add-key-value-pair-to-keystore-from-command-line/224941/6 "2020-04-27T11:34:23Z")

</div>

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