关于版本
内容 | 版本 |
---|---|
Elasticsearch版本 | 7.2.0 |
Elasticsearch 启用安全策略
根据官方文档,Elasticsearch 启用安全策略需要下面的步骤。
-
验证当前版本是否支持安全功能
-
是否打开安全设置
-
基于FIPS的一些验证
-
配置节点间通讯传输的安全性
-
配置内置用户的密码
-
选择用户验证用户身份的领域类型
-
设置角色和用户以控制对Elasticsearch的访问
-
启用审核以跟踪与Elasticsearch集群的尝试和成功的交互
上面是所有安全策略需要配置的内容,但是对于仅仅是启用账号密码这种最处理的安全策略我们只需要考虑下面几步。
- 验证当前版本是否支持安全功能
- 是否打开安全设置
- 配置节点间通讯传输的安全性
- 配置内置用户的密码
- (假如使用了kibana)修改kibana的配置
1. 验证当前版本是否支持安全功能
Elasticsearch的安全策略需要X-Pack
插件的支持,不过对于7.X以上版本X-Pack
已经内置,所以不需要额外的操作。
而关于安全功能的支持,根据官方的购买说明(https://www.elastic.co/cn/subscriptions) 除了开源版之外其他版本都支持安全策略。
2. 是否打开安全设置
xpack.security.enabled
控制安全配置的开启,在默认情况下此参数被设置为false
。要想开启安全策略需要在所有集群中讲此参数进行设置
xpack.security.enabled = true
3. 配置节点间通讯传输的安全性
仅仅开启安全设置再启动服务的时候会抛出错误
[2]: Transport SSL must be enabled if security is enabled on a [basic] license. Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting [xpack.security.enabled] to [false]
这是因为传输网络层用于集群中节点之间的内部通信。启用安全功能后,必须使用TLS来确保节点之间的通信已加密。为节点间通讯配置安全策略需要两个步骤:
-
生成节点间安全策略使用的证书
-
修改各个节点的安全配置
3. 1 创建证书颁发机构以及为节点生成证书
在Elasticsearch集群中验证证书真实性的推荐方法是信任签署证书的证书颁发机构(CA)。这样,将节点添加到群集后,它们只需要使用由同一CA签名的证书,即可自动允许该节点加入群集。另外证书中可以包含与节点的IP地址和DNS名称相对应的主题备用名称
,以便可以执行主机名验证。
*为Elasticsearch集群创建发证机构
使用下面的步骤为集群创建一个CA授权证书,
bin/elasticsearch-certutil ca
整个创建过程是这样的。在输入命令后控制台会输出此命令的信息描述,然后你需要先执行{①}的操作然后执行{②}的操作
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.
The 'ca' mode generates a new 'certificate authority'
This will create a new X.509 certificate and private key that can be used
to sign certificate when running in 'cert' mode.
Use the 'ca-dn' option if you wish to configure the 'distinguished name'
of the certificate authority
By default the 'ca' mode produces a single PKCS#12 output file which holds:
* The CA certificate
* The CA's private key
If you elect to generate PEM format certificates (the -pem option), then the output will
be a zip file containing individual files for the CA certificate and private key
Please enter the desired output file [elastic-stack-ca.p12]: {