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


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.



cat /file/containing/setting/value | bin/elasticsearch-keystore add --stdin

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).

Oh I see.

@rjernst WDYT?

1 Like

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,

1 Like

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?

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

Instructions for automating password setup are here:


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

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