# Set my passwords using x-pack/setup-passwords from script?

**URL:** <https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324>\
**Category:** Elasticsearch\
**Created:** [March 9, 2018, 6:38pm UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324 "2018-03-09T18:38:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sbu/32/27718_2.png) [@sbu](https://discuss.elastic.co/u/sbu)\
**Post date:** [March 9, 2018, 6:38pm UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324/1 "2018-03-09T18:38:59Z")

</div>

Hi,

I'm trying to build a Terraform script (could be anything though) to install ES and Kibana, it's almost working. But when it comes to ...

```
/usr/share/elasticsearch/bin/x-pack/setup-passwords interactive

```

Setting the passwords for ES and kibana, I'm at a loss. I'm thinking I could set this as a parameter which is input at the start of the Terraform run, which is fine. I'm just not sure how I can get the set-passwords command to accept input which is not from the keyboard. Any suggestions?

I could use the **auto** option, but that would make the passwords VERY difficult to grab from the terraform logs, so not an option.

Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 9, 2018, 6:57pm UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324/2 "2018-03-09T18:57:12Z")

</div>

This? [https://www.elastic.co/guide/en/elasticsearch/reference/6.2/secure-settings.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/secure-settings.html)

```auto
cat /file/containing/setting/value | bin/elasticsearch-keystore add --stdin the.setting.name.to.set

```

---

<div class="post-metadata">

**Author:** ![sbu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sbu/32/27718_2.png) [@sbu](https://discuss.elastic.co/u/sbu)\
**Post date:** [March 10, 2018, 9:51am UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324/3 "2018-03-10T09:51:08Z")

</div>

Yes, that's exactly the kind of thing we need to do except it needs to be on the initial install, using the x-pack/setup-passwords command, which doesn't have a --stdin option (at least not on the usage page).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2018, 10:29am UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324/4 "2018-03-10T10:29:47Z")

</div>

Oh I see.

@rjernst WDYT?

---

<div class="post-metadata">

**Author:** ![sbu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sbu/32/27718_2.png) [@sbu](https://discuss.elastic.co/u/sbu)\
**Post date:** [March 12, 2018, 9:43am UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324/5 "2018-03-12T09:43:55Z")

</div>

We don't have any specific requirement for running x-pack/setup-passwords, but we just want to do the whole "automate all the things" to install ES, x-pack, kibana and have a working cluster from our Terraform scripts. I'm guessing this most be a fairly common requirement!?

If there's some other way of achieving the same thing, I'd love to hear that as well.

Many thanks,

---

<div class="post-metadata">

**Author:** ![sbu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sbu/32/27718_2.png) [@sbu](https://discuss.elastic.co/u/sbu)\
**Post date:** [March 14, 2018, 9:41am UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324/6 "2018-03-14T09:41:18Z")

</div>

Another option would be to call the API and set the passwords that way, but I'm not sure how we should grab the initial seeded password that elastic sets up. Obviously the setup-passwords script knows how to do this, but I don't know what they are set to. Any ideas?

---

<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:** [March 14, 2018, 11:37pm UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324/7 "2018-03-14T23:37:35Z")

</div>

I've moved this to the `X-Pack` forum.

Instructions for automating password setup are here:

> [@How to set passwords for built-in users in batch mode?](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/6):
>
> @Vitaly_il how I may submit bootstrapping password to \_xpack/security/user/.../\_password API Step 0: Think of a password to use. I'll use "top-secret" Step 1: Shutdown at least 1 node of your cluster. Step 2: Add a "bootstrap.password" to the keystore on that node: bin/elasticsearch-keystore add "bootstrap.password" Enter value for bootstrap.password: top-secret Step 3: Start that elasticsearch node. Step 4: Call curl -uelastic -XPUT -H 'Content-Type: application/json' 'http://localhos…

---

<div class="post-metadata">

**Author:** ![sbu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sbu/32/27718_2.png) [@sbu](https://discuss.elastic.co/u/sbu)\
**Post date:** [March 16, 2018, 9:32am UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324/8 "2018-03-16T09:32:21Z")

</div>

Nice one, thanks. That's working perfectly now using that method.

---

<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 13, 2018, 9:32am UTC](https://discuss.elastic.co/t/set-my-passwords-using-x-pack-setup-passwords-from-script/123324/9 "2018-04-13T09:32:24Z")

</div>

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