Elastic 安全配置 开启xpack

1、生成证书

bin/elasticsearch-certutil ca
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
mv bin/elastic-certificates.p12 config/
mv bin/elastic-stack-ca.p12 config/

2、编辑elasticsearch.yml
开启xpack

xpack.security.enabled: true

3、开启集群中https传输

xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

4、开启api接口https传输

xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: elastic-certificates.p12
xpack.security.http.ssl.truststore.path: elastic-certificates.p12

xpack.security.http.ssl.client_authentication: none
xpack.ssl.verification_mode: none

5、自动生成密码

bin/elasticsearch-setup-passwords auto

6、配置kibana.yml
因为开启了elastic https传输所以要把http改为https

elasticsearch.hosts: ["https://localhost:9200"]

配置刚刚生成的kibana用户名和密码,否则启动kibana会报错

elasticsearch.username: "kibana"
elasticsearch.password: "puVIrhabjDNOMFCybZZj"

ssl证书认证为none

elasticsearch.ssl.verificationMode: none
Elasticsearch 7.9版本开始,基于XPack安全性插件的鉴权功能已经在开源版本中被移除。如果您使用的是Elasticsearch 8.2版本或更高版本,您需要购买商业许可证并安装Elasticsearch的安全性扩展才能启用鉴权功能。 安全性扩展提供了一套完整的安全解决方案,包括身份验证、角色管理、SSL/TLS支持等。您可以在Elasticsearch官方网站上了解有关Elasticsearch安全性扩展的更多信息,并获取相应的许可证。 一旦安装并配置安全性扩展,您可以通过以下步骤来启用HTTP鉴权: 1. 在elasticsearch.yml配置文件中,设置以下参数来启用安全性功能: ``` xpack.security.enabled: true ``` 2. 在elasticsearch.yml配置文件中,配置超级用户的用户名和密码: ``` xpack.security.authc: realms: native: native1: order: 0 native: order: 1 ``` 3. 重启Elasticsearch以使配置生效。 4. 使用超级用户的用户名和密码进行身份验证。可以通过在HTTP请求头中添加Authorization字段来进行身份验证。例如,在curl命令中可以使用以下方式进行鉴权: ``` curl -u username:password http://localhost:9200/_cluster/health ``` 请注意,在真实环境中,建议使用更强大的身份验证方法,如SSL/TLS证书进行加密通信和身份验证。 请确保在进行任何安全配置之前,详细阅读Elasticsearch的安全性文档,并了解所有相关安全配置的潜在风险和最佳实践。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值