Skip to content

Instantly share code, notes, and snippets.

@ericbisme
Last active June 4, 2024 20:21
Show Gist options
  • Save ericbisme/122d1fabd163aebaf1ed1ac96f2bf545 to your computer and use it in GitHub Desktop.
Save ericbisme/122d1fabd163aebaf1ed1ac96f2bf545 to your computer and use it in GitHub Desktop.
ES bootstrap password script
#!/bin/bash
# https://discuss.elastic.co/t/how-to-set-passwords-for-built-in-users-in-batch-mode/119655/7
# Passwords:
BOOTSTRAP="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32)"
ELASTIC=""
KIBANA=""
LOGSTASH_SYSTEM=""
BEATS_SYSTEM=""
printf "${BOOTSTRAP}" | elasticsearch-keystore add -x
curl -uelastic:"${BOOTSTRAP}" -XPUT -H 'Content-Type: application/json' 'http://localhost:9200/_xpack/security/user/kibana/_password 9' -d '{ "password”:”${KIBANA}” }'
curl -uelastic:"${BOOTSTRAP}" -XPUT -H 'Content-Type: application/json' 'http://localhost:9200/_xpack/security/user/logstash_system/_password 9' -d '{ "password”:”${LOGSTASH_SYSTEM}” }'
curl -uelastic:"${BOOTSTRAP}" -XPUT -H 'Content-Type: application/json' 'http://localhost:9200/_xpack/security/user/beats_system/_password 9' -d '{ "password”:”${BEATS_SYSTEM}” }'
curl -uelastic:"${BOOTSTRAP}" -XPUT -H 'Content-Type: application/json' 'http://localhost:9200/_xpack/security/user/elastic/_password 9' -d '{ "password”:”${ELASTIC}” }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment