标签:
ELK 和 Shield 2.0+ 都安装在 10.100.100.60服务器
1、对Elasticsearch 安装 Shield
bin/plugin install license
bin/plugin install shield
2、运行 Elasticsearch
bin/elasticsearch
3、添加一个admin 用户
bin/shield/esusers useradd es_admin -r admin
输入密码 123456
登录 es_admin 123456 ,可以看到所有的 indices
4、测试用户是否写入
页面登录 http://10.100.100.60:9200/ 需要输入用户名和密码 es_admin 123456
5、对kibana 写入Shield
curl -u es_admin -XPOST ‘http://10.100.100.60:9200/_shield/user/kibana-server‘ -d ‘{"password" : "123456", "roles" : [ "kibana4_server"]}}‘
返回 {"user":{"created":true}}
修改kibana 配置文件:
/config/kibana.yml.
elasticsearch.username: "kibana4-server" elasticsearch.password: "123456"
修改 roles.yml
/data/elasticsearch/config/shield/roles.yml
加入 kibana_redis 角色,只给 logstash-redis-input 可读权限,.kibana 读写管理权限
kibana_redis: cluster: - monitor indices: - names: ‘logstash-redis-input-*‘ privileges: - view_index_metadata - read - names: ‘.kibana*‘ privileges: - manage - read - index
6、添加一个用户 es_kibana 给角色 kibana_redis
bin/shield/esusers useradd es_kibana -r kibana_redis
输入密码 123456
输入 es_kibana 123456 登录
如下图,只有点击 logstash-redis-input-* 和 .kibana 的indices 才能看到数据,其他的都没有
7、kibana 的 kibana_redis 角色给予登录信息
curl -u es_kibana -XPOST ‘http://10.100.100.60:9200/_shield/user/kibana-server‘ -d ‘{"password" : "123456", "roles" : [ "kibana_redis"]}}‘
失败报错:
{"error":{"root_cause":[{"type":"security_exception","reason":"unable to authenticate user [es_kibana] for REST request [/_shield/user/kibana-server]","header":{"WWW-Authenticate":"Basic realm=\"shield\""}}],"type":"security_exception","reason":"unable to authenticate user [es_kibana] for REST request [/_shield/user/kibana-server]","header":{"WWW-Authenticate":"Basic realm=\"shield\""}},"status":401}
再次修改 user后用户为 es_kibana
curl -u es_kibana -XPOST ‘http://10.100.100.60:9200/_shield/user/es_kibana‘ -d ‘{"password" : "123456", "roles" : [ "kibana_redis"]}}‘
返回 {"user":{"created":true}} 成功
8、登录 kibana
登录 es_kibana 123456
如下图,只有点击 logstash-redis-input-* ,会有数据(图8-1),其他的(图8-2),会报错
图 8-1
图 8-2
附上官网解释:
With Shield installed, if you load a Kibana dashboard that accesses data in an index that you are not authorized to view, you get an error that indicates the index does not exist. Kibana and Shield do not currently provide a way to control which users can load which dashboards.
安装了Shield,如果你加载一个Kibana仪表盘,你未被授权访问数据索引、视图,你得到一个错误,表明该indices不存在。Kibana和Shield目前并不能提供一种方法来控制哪些用户可以加载哪些仪表板。
Shield 2.0+ 配合Elasticsearch 和 kibana 的使用
标签:
原文地址:http://www.cnblogs.com/wjq310/p/5846895.html