设置密码
1. 在docker-compose 中添加配置,开启验证功能
在docker-compose.xml 的 environment 项下添加:
xpack.security.enabled: true
2. 进入docker 容器
3. 随机生成密码用auto, 自己设置用 interactive
[root@njfdkb4bmk3b elasticsearch]# ./bin/elasticsearch-setup-passwords -h
Sets the passwords for reserved users
Commands
--------
auto - Uses randomly generated passwords
interactive - Uses passwords entered by a user
Non-option arguments:
command
Option Description
------ -----------
-E <KeyValuePair> Configure a setting
-h, --help Show help
-s, --silent Show minimal output
-v, --verbose Show verbose output
[root@cfeeab4bb0eb elasticsearch]# ./bin/elasticsearch-setup-passwords auto
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
The passwords will be randomly generated and printed to the console.
Please confirm that you would like to continue [y/N]y
Changed password for user apm_system
PASSWORD apm_system = gSvCaOHWoFD4dpvLaYAZ
Changed password for user kibana_system
PASSWORD kibana_system = cFVJwGqIWVgE8jrl5nV4
Changed password for user kibana
PASSWORD kibana = cFVJwGqIWVgE8jrl5nV4
Changed password for user logstash_system
PASSWORD logstash_system = vMTzzb8aiPMrmPsFp2ro
Changed password for user beats_system
PASSWORD beats_system = oXwGPfH60RyDchGDjiKw
Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = hw7Ypaq4jU7f19Zjgtcc
Changed password for user elastic
PASSWORD elastic = NF42bCrlkISg9uCIH5nJ
忘记密码
1.创建一个临时的超级用户 admin及密码(pwd123)
./bin/elasticsearch-users useradd admin -r superuser
Enter new password:
ERROR: Invalid password...passwords must be at least [6] characters long
[root@cfeeab4bb0eb elasticsearch]# ./bin/elasticsearch-users useradd admin -r superuser
Enter new password:
Retype new password:
用这个用户去修改elastic用户的密码:
curl -XPUT -u admin:pwd123 http://localhost:9200/_xpack/security/user/elastic/_password -H
"Content-Type: application/json" -d '
{
"password": "q5f2qNfUJQyvZPIz57MZ"
}'