Elastic Search - Xpack 安全密码更改

Elastic Search - Xpack security password change

我使用以下命令为弹性搜索生成了密码,但我忘记复制和备份控制台输出中显示的密码

sudo -E ./elasticsearch-setup-passwords auto

当我再次尝试执行它时,我无法再次重新生成密码,请帮助我获取这些密码或指导我如何更改用户 elastic[= 的密码11=]

来自official documentation

The elasticsearch-setup-passwords command uses a transient bootstrap password that is no longer valid after the command runs successfully. You cannot run the elasticsearch-setup-passwords command a second time. Instead, you can update passwords from the Management > Users UI in Kibana or use the security user API.

如粗体部分所述,您只需从 Kibana UI.

更新密码即可

如果您由于密码无效和身份验证错误而无法登录 kibana,请使用以下流程

  1. 停止弹性搜索
  2. 转到目录elasticsearch/bin
  3. 通过下面创建新的超级用户

./elasticsearch-users useradd elasticadmin -p elasticadmin -r superuser

  1. 启动elasticsearch进程

  2. 用新用户尝试 运行 下面的命令你应该得到用户列表:

curl -u elasticadmin -XGET 'http://localhost:9200/_xpack/security/user?pretty'

Enter host password for user 'newadmin':

{ "elastic" : { "username" : "elastic", "roles" : [ "superuser" ], "full_name" : null, "email" : null, "metadata" : { "_reserved" : true }, "enabled" : true }, "kibana" : { "username" : "kibana", "roles" : [ "kibana_system" ], "full_name" : null,

  1. 运行 下面的 curl 命令更改 elastic 用户的密码。

curl --user elasticadmin:#l@$t!c@dm!n -XPUT "http://localhost:9200/_xpack/security/user/elastic/_password?pretty" -H 'Content-Type: application/json' -d'{ "password" : "typeyourpasswordhere"}'

  1. 尝试使用elastic用户的新密码登录elasticsearch

curl -u elastic -XGET "http://localhost:9200/"

  1. 类似的方法你可以修改kibana或者其他用户的密码