参考文章:
https://www.elastic.co/cn/blog/getting-started-with-elasticsearch-security
进入到es的配置文件 /etc/elasticsearch/elasticsearch.yml
添加如下配置
xpack.security.enabled: true
重启es服务
sudo systemctl start elasticsearch.service
切换进入 cd /usr/share/elasticsearch/
执行命令自动生成密码 sudo bin/elasticsearch-setup-passwords auto
[root@iZbp1daozbxh8x2mj4oosrZ elasticsearch]# bin/elasticsearch-setup-passwords auto Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,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]
会生成对应的密码
`Changed password for user apm_system
PASSWORD apm_system = Aw*****3
Changed password for user kibana_system
PASSWORD kibana_system = Uo4zhTr*****KWR1
Changed password for user kibana
PASSWORD kibana = Uo4zhTrO*****KWR1
Changed password for user logstash_system
PASSWORD logstash_system = TwB*****KXb
Changed password for user beats_system
PASSWORD beats_system = C8DU*****6Fg
Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = SREKj*****fZT
Changed password for user elastic
PASSWORD elastic = mjA*****RZr
elasticsearch.username: "elastic"
elasticsearch.password: "mjA*****Zr"`
进入到kibana的配置 添加es的用户名和密码
elasticsearch.username: "elastic" elasticsearch.password: "mjA27GddBjwDFrIn7RZr"
重启kibana服务即可