ELK之ElasticSearch 6.X安全认证Search Guard(demo01)
Table of Contents
ElasticSearch单节点安装Search Guard插件
1 | 版本介绍: |
- Search Guard(安全认证)插件安装
切换到ElasticSearch安装目录,通过使用elasticsearch plugin命令安装Search Guard插件
1 | ./bin/elasticsearch-plugin install -b com.floragunn:search-guard-6:<version> |
1 | 例:./bin/elasticsearch-plugin install -b com.floragunn:search-guard-6:6.6.2-24.2 |
- 基于在线方式生成TLS证(官方提供多中方式生成)
在线生成地址:https://search-guard.com/tls-certificate-generator/
服务器hosts配置
- 配置证书
证书文件会发送到邮箱中,目录结构如下。详细描述参考证书目录下README.txt1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24search-guard-certificates-<UUID>.tar.gz
│
└─── client-certificates
│ Contains two client certificates named 'admin' and 'demouser'
│ The 'admin' certificate can be used with sgadmin and the REST API.
│ The CN of this certificate is 'sgadmin'. The demouser certificate can be used
│ for HTTPS client authentication. The CN of this certificate is 'demouser'
└─── node-certificates
│ Contains the certificates in jks, p12 and pem format to be used
│ on your Elasticsearch nodes. You will find certificates for all
│ hostnames you specified when submitting the form.
└─── root-ca
│ Contains the root CA certificate and private key in PEM format.
└─── config
│ Same as above, but for the signing CA
└─── truststore.jks
│ The truststore containing the certificate chain
│ of the root and signing CA, and the root certificate and private key in PEM format.
│ Can be used on all nodes.
└─── root-ca.pem
│ The root CA in PEM format.
│ Can be used on all nodes.
└─── chain-ca.pem
│ The certificate chain containg the root and signing CA in PEM format.
参考README.txt 复制证书及修改ES_HOME/config/elasticsearch.yml配置,配置如下:
1 | /** |
至此配置告一段落,切换用户启动es,执行以下命令,注意密码查看README.txt
1 | cd ES_HOME/plugins/search-guard-<version>/tools |
命令输出如下
- 见证奇迹时刻!!!
打开浏览器输入http://IP:9200/_searchguard/authinfo,成功弹出登录提示框!输入admin:admin登录成功
- 权限配置
创建一个用户:
–用户名:colin
–密码:colin,
–权限:kibana服务权限、只有索引【colin】crud权限,没有logstash权限)1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32内部数据库目录结构(ES_HOME/plugins/search-guard-<version>/sgconfig/)
--sg_internal_users.yml 用户信息
--sg_roles.yml 权限设置
--sg_roles_mapping.yml 映射权限和用户关系
#创建用户
vim sg_internal_users.yml #添加用户信息
#password is: colin
colin:
readonly: true
hash: $2y$12$8YYO/iYi1k31G5avwHonfOGfv5F/NTIMzPxtziVBg8FIf3q979iiO
roles:
- sg_role_colin
- kibanauser
#添加权限
vim sg_roles.yml #添加权限
sg_role_colin:
cluster:
- UNLIMITED
indices:
'colin':
'*':
- INDICES_ALL
# _dls_: '<dls query>'
# _fls_:
# - '<field>'
# - '<field>'
#使配置立即生效
cd ES_HOME/plugins/search-guard-<version>/tools
./sgadmin.sh -ts truststore.jks -tspass 286a7b7a8970af4e8467 -ks CN=sgadmin-keystore.jks -kspass 449e1fcd3cba8bb7d491 -nhnv -icl -cd ../sgconfig/
权限配置完成通过kibana查看效果,如下
- 查询colin索引,结果正常
- 查询wl_travel索引,提示无权操作
评论系统未开启,无法评论!