【ELK】为elastic stack设置基础安全

本文中Elasticsearch安装在/data/elasticsearch/目录下,另外需要在/data/elasticsearch/config/目录下新建certs目录。

# 生成CA证书
/data/elasticsearch/bin/elasticsearch-certutil ca -out /data/elasticsearch/config/certs/elastic-stack-ca.p12
 
# 生成证书密钥
/data/elasticsearch/bin/elasticsearch-certutil cert --ca /data/elasticsearch/config/certs/elastic-stack-ca.p12 -out /data/elasticsearch/config/certs/elastic-certificates.p12

备注:如果elasticsearch安装为多节点集群,只需在一个节点上生成证书和密钥,然后将证书和密钥复制到其他节点上的/data/elasticsearch/config/certs目录下即可

# 增加xpack配置
vi /data/elasticsearch/config/elasticsearch.yml
-------每一行前面都要保留一个空格,否则会启动报错失败------------
 xpack.security.enabled: true
 xpack.license.self_generated.type: basic
 xpack.security.transport.ssl.enabled: true
 xpack.security.transport.ssl.verification_mode: certificate
 xpack.security.transport.ssl.client_authentication: required
 xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
 xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

# 重新启动Elastic
/data/elasticsearch/bin/elasticsearch -d

# 创建用户密码(elastic、apm_system、kibana_system、logstash_system、beats_system、remote_monitoring_user)
# /data/elasticsearch/bin/elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y

Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana_system]: 
Reenter password for [kibana_system]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]

备注:如果是多节点集群,需要集群的所有节点都成功启动,才能成功设置apm_system用户的密码,否则apm_system密码的设置将会失败。

这时再访问 http://192.168.223.101:9200/,会弹出登录框,输入刚才为elastic用户设置的用户密码即可完成登录。

 另外,在Kibana和filebeat的配置文件中,需要将配置指定用户的密码。

参考:

Set up basic security for the Elastic Stack | Elasticsearch Guide [7.16] | Elastic

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cnskylee

技术分享我是认真的,期待您打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值