使用.yml文件更改elasticsearch中的默认密码

问题描述 投票:0回答:2

如果我有一个elasticsearch.yml配置文件,是否可以更改默认密码?我在.yml文件中添加了什么来做到这一点?现在它的changeme

我正在使用Elasticsearch 5.6.4

我的.yml文件

cluster.name: "docker-cluster"
network.host: "0.0.0.0"

http.cors.enabled : true
http.cors.allow-origin : "*"
http.cors.allow-methods : "OPTIONS, HEAD, GET, POST, PUT, DELETE"
http.cors.allow-headers : "X-Requested-With, X-Auth-Token, Content-Type, Content-Length, Authorization"
elasticsearch elasticsearch-x-pack
2个回答
2
投票

您可以通过API更改密码,如下所示:

POST _xpack/security/user/elastic/_password
{
  "password": "whatever"
}

或者,如果你忘了它或类似的话:https://discuss.elastic.co/t/i-lost-the-password-that-has-been-changed/91867/2

但是你不能做类似于elasticsearch.yml文件的任何事情。


0
投票

Andrei回答有效,但可能有问题,因为实例必须运行,您必须已经过身份验证。

以下适用于6.7及以上版本,更像是我想要的解决方案,使用自定义密码启动elasticsearch。

echo "<boot_password>" | bin/elasticsearch-keystore add -xf bootstrap.password

所以我的dockerfile看起来像这样

FROM docker.elastic.co/elasticsearch/elasticsearch:6.7.1

RUN echo "<boot_password>" | bin/elasticsearch-keystore add -xf bootstrap.password

COPY ./config/elasticsearch.yml /usr/share/elasticsearch/config/elasticsearch.yml

现在您可以使用连接

username: elastic

password: <boot_password>

© www.soinside.com 2019 - 2024. All rights reserved.