博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Elasticsearch & Kibana with Shield
阅读量:4574 次
发布时间:2019-06-08

本文共 4773 字,大约阅读时间需要 15 分钟。

Elasticsearch & Kibana with Shield
 
官方网站:
 
 
环境:
kibana-4.5.0
elasticsearch-2.3.2
shield-2.3.2
license-2.3.2
 
 
前言:
Shield作为安全插件可以嵌入到ELK当中,商业授权,前30天免费
支持多种认证方式
nativefileLDAPActive DirectoryPKI,详情见
这里以file,native为例
 
 
Elasticsearch with Shield
一.停止所有elasticsearch节点
说明:shield安装,卸载,升级都需要重启elasticsearch节点
 
二.安装shield插件(所有elasticsearch节点)
说明:shield版本必须和elasticsearch保持一致
在线安装

/opt/elasticsearch-2.3.2/bin/plugin install license

/opt/elasticsearch-2.3.2/bin/plugin install shield

或离线安装

wget 
wget 
/opt/elasticsearch-2.3.2/bin/plugin install file:///root/license-2.3.2.zip 
/opt/elasticsearch-2.3.2/bin/plugin install file:///root/shield-2.3.2.zip
 

[root@ela-master1 ~]# /opt/elasticsearch-2.3.2/bin/plugin install file:///root/license-2.3.2.zip 

-> Installing from file:/root/license-2.3.2.zip...

Trying file:/root/license-2.3.2.zip ...

Downloading .DONE

Verifying file:/root/license-2.3.2.zip checksums if available ...

NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify)

Installed license into /opt/elasticsearch-2.3.2/plugins/license

[root@ela-master1 ~]# /opt/elasticsearch-2.3.2/bin/plugin install file:///root/shield-2.3.2.zip

-> Installing from file:/root/shield-2.3.2.zip...

Trying file:/root/shield-2.3.2.zip ...

Downloading .......................DONE

Verifying file:/root/shield-2.3.2.zip checksums if available ...

NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify)

Installed shield into /opt/elasticsearch-2.3.2/plugins/shield

 
注意:一旦shield安装成功,在elasticsearch重启后,对elasticsearch的任何操作都需要授权(用户名和密码),除非启用匿名用户
 
三.配置realm
A.配置file-realm(所有节点)
1.增加file-realm配置
cat >>/opt/elasticsearch-2.3.2/config/elasticsearch.yml <<HERE

shield.authc.realms.file1.type: file

shield.authc.realms.file1.order: 0

HERE

2.启动(或重启)elasticsearch

3.创建file based用户

/opt/elasticsearch-2.3.2/bin/shield/esusers useradd es_admin -p P@ssw0rd -r admin

/opt/elasticsearch-2.3.2/bin/shield/esusers useradd kibana -p P@ssw0rd -r kibana4_server

[root@ela-client ~]# /opt/elasticsearch-2.3.2/bin/shield/esusers list

es_admin       : admin

kibana         : kibana4_server

说明:这里创建了两个用户es_admin(用户名 es_admin, 密码P@ssw0rd, 角色admin)和kibana,用户角色定义可以参看shield配置文 件/opt/elasticsearch-2.3.2/config/shield/roles.yml
4.file based用户同步到集群其它节点
注意:对于用户和角色的所有操作默认都存放在如下位置,因此集群中的所有节点都需要上面同样的操作,当然,也可以直接copy如下文件到其它节点的对应目录

/opt/elasticsearch-2.3.2/config/shield/users

/opt/elasticsearch-2.3.2/config/shield/users_roles

5.测试用户认证

[root@ela-client ~]# curl -u es_admin:P@ssw0rd 'http://localhost:9200/_cat/health?v'

epoch      timestamp cluster               status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent 

1462705707 19:08:27  elasticsearch_cluster green           6         2     52  26    0    0       0             0                  -                100.0% 

[root@ela-client ~]# curl -u es_admin:P@ssw0rd 'http://localhost:9200/_cat/indices?v'

health status index               pri rep docs.count docs.deleted store.size pri.store.size 

green  open   shakespeare           5   1     111396            0     36.5mb         18.2mb 

green  open   logstash-2015.05.20   5   1       4750            0     72.9mb         35.7mb 

green  open   bank                  5   1       1000            0    890.5kb       447.9kb 

green  open   .kibana               1   1          4            0     44.5kb        22.2kb 

green  open   logstash-2015.05.18   5   1       4631            0     64.9mb         32.7mb 

green  open   logstash-2015.05.19   5   1       4624            0     66.7mb           32mb 

 

B.配置native-realm(所有节点)
默认情况下, native-realm已经被配置到了realm链里, 可以直接通过
REST API来添加删除用户,修改用户密码及管理角色, 这也是
官方推荐的认证方式
1.增加native-realm配置
cat >>/opt/elasticsearch-2.3.2/config/elasticsearch.yml <<HERE

shield.authc.realms.native1.type: native

shield.authc.realms.native1.order: 0

HERE

2.启动(或重启)elasticsearch

3.创建native用户

curl -u es_admin:P@ssw0rd -XPOST 'http://localhost:9200/_shield/user/fooadmin' -d '

{

  "password" : "foo.123", 

  "roles" : [ "admin", "other_role1" ], 

  "full_name" : "Jlive Liu", 

  "email" : "iliujun_live@163.com", 

  "metadata" : { 

    "intelligence" : 7

  }

}

'

说明:

1.新增native用户也需要认证,但启用了shield之后默认是没有native用户的,所以就需要借助file based用户来授权

2.native用户是存放在elasticsearch集群中,集群中的所有节点会自动同步

[root@ela-client ~]# curl -u es_admin:P@ssw0rd -XPOST 'http://localhost:9200/_shield/user/fooadmin' -d '

{

  "password" : "foo.123", 

  "roles" : [ "admin", "other_role1" ], 

  "full_name" : "Jlive Liu", 

  "email" : "iliujun_live@163.com", 

  "metadata" : { 

    "intelligence" : 7

  }

}

'

 

{"user":{"created":true}}

[root@ela-data1 ~]# curl -u es_admin:P@ssw0rd 'http://localhost:9200/_shield/user'

{"fooadmin":{"username":"fooadmin","roles":["admin","other_role1"],"full_name":"Jlive Liu","email":"iliujun_live@163.com","metadata":{"intelligence":7}}}

4.测试用户认证

[root@ela-master2 ~]# curl -u fooadmin:foo.123 'http://localhost:9200/_cat/health?v'

epoch      timestamp cluster               status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent 

1462707192 19:33:12  elasticsearch_cluster green           6         2     54  27    0    0       0             0                  -                100.0% 

 

转载于:https://www.cnblogs.com/bmaker/p/5731319.html

你可能感兴趣的文章
小技巧
查看>>
python接口自动化20-requests获取响应时间(elapsed)与超时(timeout) ok试了 获取响应时间的...
查看>>
linux打包压缩与搜索命令
查看>>
冒泡排序
查看>>
windows phone 三种数据共享的方式(8)
查看>>
阶段1 语言基础+高级_1-3-Java语言高级_02-继承与多态_第1节 继承_13-Java继承的三个特点...
查看>>
阶段1 语言基础+高级_1-3-Java语言高级_05-异常与多线程_第1节 异常_14_自定义异常类的练习...
查看>>
第五周总结
查看>>
Poj 2328 Guessing Game(猜数字游戏)
查看>>
Hibernate基础知识
查看>>
20150518 字符设备驱动
查看>>
UIView的动画之初步学习
查看>>
中小企业实施OA的意义
查看>>
es6 数组
查看>>
JS判断是否在微信浏览器打开
查看>>
javascript中typeof和instanceof的区别
查看>>
数据结构-数组1
查看>>
jquery之别踩白块游戏的实现
查看>>
转载Eclipse中Maven WEB工程tomcat项目添加调试
查看>>
caller和callee的解析与使用-型参与实参的访问
查看>>