# How to set passwords for built-in users in batch mode?

**URL:** <https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655>\
**Category:** Elasticsearch\
**Created:** [February 13, 2018, 2:18pm UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655 "2018-02-13T14:18:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitaly\_il](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vitaly_il/32/130964_2.png) [@Vitaly\_il](https://discuss.elastic.co/u/Vitaly_il)\
**Post date:** [February 13, 2018, 2:18pm UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/1 "2018-02-13T14:18:23Z")

</div>

I'd like to use "setup-passwords interactive" for settings passwords in my setup script.  
This command works nice in manual mode, but for some reason fails with

```
Exception in thread "main" java.lang.NullPointerException
	at org.elasticsearch.cli.Terminal$SystemTerminal.readSecret(Terminal.java:174)
	at org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool$InteractiveSetup.promptForPassword(SetupPasswordTool.java:191)
	at org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool$InteractiveSetup.lambda$execute$0(SetupPasswordTool.java:184)
	at org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool$SetupCommand.changePasswords(SetupPasswordTool.java:380)
	at org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool$InteractiveSetup.execute(SetupPasswordTool.java:184)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
	at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:75)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool.main(SetupPasswordTool.java:105)

```

exception when I submitting my answers automatically, inside script. I tried "here document" and other standart ways - the same issue.

Any ideas how to set up passwords via script?

TIA,  
Vitaly

---

<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:** [February 14, 2018, 1:47am UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/2 "2018-02-14T01:47:12Z")

</div>

> [@Vitaly\_il](#):
>
> Any ideas how to set up passwords via script?

The setup-passwords tool isn't designed to be scriptable.  
All it is doing it scripting some API call calls to set passwords.  
The intent is that you would call the `_xpack/security/user/.../_password` API directly if you want to automate it.

---

<div class="post-metadata">

**Author:** ![Vitaly\_il](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vitaly_il/32/130964_2.png) [@Vitaly\_il](https://discuss.elastic.co/u/Vitaly_il)\
**Post date:** [February 15, 2018, 9:13am UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/3 "2018-02-15T09:13:21Z")

</div>

Thank you!  
Unfortunately, even after reading [https://www.elastic.co/guide/en/x-pack/6.2/setting-up-authentication.html#bootstrap-elastic-passwords](https://www.elastic.co/guide/en/x-pack/6.2/setting-up-authentication.html#bootstrap-elastic-passwords) and other docs, I still couldn't understand how I may submit bootstrapping password to \_xpack/security/user/.../\_password API.

---

<div class="post-metadata">

**Author:** ![John\_saida](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@John\_saida](https://discuss.elastic.co/u/John_saida)\
**Post date:** [February 17, 2018, 12:04pm UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/4 "2018-02-17T12:04:28Z")

</div>

Hi I am John,  
I was installed xpack in elastic search ....  
How to check xpack installed for not ?  
How open elastic search in local Host in Windows machine?  
How to set default password elastic search?  
How to change password in elastic search?

---

<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:** [February 17, 2018, 8:30pm UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/5 "2018-02-17T20:30:24Z")

</div>

@John_saida, Please start a separate thread for your questions.

---

<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:** [February 19, 2018, 1:02am UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/6 "2018-02-19T01:02:59Z")

</div>

@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:

```auto
bin/elasticsearch-keystore add "bootstrap.password"
Enter value for bootstrap.password: top-secret

```

Step 3: Start that elasticsearch node.

Step 4: Call

```auto
curl -uelastic -XPUT -H 'Content-Type: application/json' 'http://localhost:9200/_xpack/security/user/kibana/_password' -d '{ "password":new-kibana-password" }'
Enter host password for user 'elastic': top-secret

```

Step 5: Repeat (4) for logstash\_system

Step 6: Repeat (4) for elastic (to set a permanent password rather than just a "bootstrap.password" that's tied to a specific node)

---

<div class="post-metadata">

**Author:** ![Vitaly\_il](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vitaly_il/32/130964_2.png) [@Vitaly\_il](https://discuss.elastic.co/u/Vitaly_il)\
**Post date:** [February 19, 2018, 2:08pm UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/7 "2018-02-19T14:08:24Z")

</div>

Tim,  
Many thanks, it works!

---

<div class="post-metadata">

**Author:** ![dao](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dao](https://discuss.elastic.co/u/dao)\
**Post date:** [March 12, 2018, 9:49am UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/8 "2018-03-12T09:49:50Z")

</div>

That is really usefull

is it possible to make it completely scriptable? I mean no password request to type in stdin?

---

<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 12, 2018, 9:59am UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/9 "2018-03-12T09:59:00Z")

</div>

> [@dao](#):
>
> is it possible to make it completely scriptable? I mean no password request to type in stdin?

```auto
printf "top-secret" | elasticsearch-keystore add -x

```

---

<div class="post-metadata">

**Author:** ![dao](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dao](https://discuss.elastic.co/u/dao)\
**Post date:** [March 12, 2018, 9:59am UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/10 "2018-03-12T09:59:52Z")

</div>

OK, and for the step 4?

---

<div class="post-metadata">

**Author:** ![Vitaly\_il](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vitaly_il/32/130964_2.png) [@Vitaly\_il](https://discuss.elastic.co/u/Vitaly_il)\
**Post date:** [March 12, 2018, 10:32am UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/11 "2018-03-12T10:32:46Z")

</div>

curl -uelastic:"top-secret" -XPUT -H 'Content-Type: application/json' '[http://localhost:9200/\_xpack/security/user/kibana/\_password](http://localhost:9200/_xpack/security/user/kibana/_password)' -d '{ "password”:”changeme” }'

---

<div class="post-metadata">

**Author:** ![dao](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dao](https://discuss.elastic.co/u/dao)\
**Post date:** [March 12, 2018, 1:15pm UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/12 "2018-03-12T13:15:52Z")

</div>

perfect, this closes the loop

---

<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 9, 2018, 1:16pm UTC](https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/13 "2018-04-09T13:16:08Z")

</div>

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