Shield 安裝與配置

https://www.elastic.co/guide/en/shield/shield-1.3/introduction.htmlhtml

 1、簡介shell

Shield是Elasticsearch的一個插件,它可以很容易的保證你的Elasticsearch集羣的安全性。安全

Shield的功能:app

1.用戶認證curl

2.SSL/TLS的加密身份驗證elasticsearch

3.審計ide

2、安裝ui

我使用的shield-1.3的版本加密

  1. 安裝Elasticsearch集羣url


  2. Shield是須要licese的,咱們只有在offline機器上安裝使用

        a.下載license https://download.elastic.co/elasticsearch/license/license-latest.zip

[root@hftclclw0001 usr]# pwd
/usr

[root@hftclclw0001 usr]# wget https://download.elastic.co/elasticsearch/license/license-latest.zip
...
...

        b. 下載 shield https://download.elastic.co/elasticsearch/shield/shield-latest.zip

[root@hftclclw0001 usr]# pwd
/usr

[root@hftclclw0001 usr]# wget https://download.elastic.co/elasticsearch/shield/shield-latest.zip
...
...

      c. 安裝license 和 shield

注意/usr/share/elasticsearch/  是elasticsearch的安裝目錄
     是本地文件的協議前綴 

[root@hftclclw0001 usr]# /usr/share/elasticsearch/bin/plugin -i license -u file:///usr/license-latest.zip
...
...

[root@hftclclw0001 usr]# /usr/share/elasticsearch/bin/plugin -i license -u file:///usr/shield-latest.zip
...
...

校驗:
[root@hftclclw0001 usr]#  ll /usr/share/elasticsearch/plugins/
...
...
license
shield
...

[root@hftclclw0001 usr]# curl -XGET '    => 此時是沒法訪問的,須要身份驗證
... 


首先建立一個管理員
[root@hftclclw0001 plugins]# /usr/share/elasticsearch/bin/shield/esusers useradd es_admin -r admin
...

[root@hftclclw0001 usr]# curl -XGET -u es_admin:{passwd} 'http://{ip}:9200/'

3、消息認證(enable message authentication)

https://www.elastic.co/guide/en/shield/shield-1.3/enable-message-authentication.html

消息驗證會驗證消息傳輸過程當中是否被篡改等

1.生成key
[root@hftclclw0001 shield]# /usr/share/elasticsearch/bin/shield/syskeygen
...

會生成 ES_HOME/config/shield/system_key

而後再elasticsearch.yml 中配置
shield.system_key.file=

2.複製key到其餘各個節點上,各個節點必須相同


4、用戶認證配置(setting up user authentication)

爲了獲取受限資源權限,用戶必須提供身份校驗信息。如密碼等。

1.esusers

    是shield內置一種方式

https://www.elastic.co/guide/en/shield/shield-1.3/esusers.html

https://www.elastic.co/guide/en/shield/shield-1.3/_managing_users_in_an_esusers_realm.html

添加用戶(Adding User)
[root@hftclclw0001 plugins]# /usr/share/elasticsearch/bin/shield/esusers useradd test_1
會提示讓你輸入密碼,

[root@hftclclw0001 plugins]# /usr/share/elasticsearch/bin/shield/esusers  useradd test-1 -p test_1
這樣就會建立一個用戶test_1 密碼是 test_1

[root@hftclclw0001 plugins]# /usr/share/elasticsearch/bin/shield/esusers list
#【userid】: 【roleid】
...
test_1         : -
...

默認角色是 -  也沒有啥權限,稍後會說明角色與權限

修改用戶密碼(Managing User Passwords)
[root@hftclclw0001 plugins]# /usr/share/elasticsearch/bin/shield/esusers passwd test-1 -p test_1


2. 基於角色的訪問控制

    https://www.elastic.co/guide/en/shield/shield-1.3/configuring-rbac.html

定義角色(Defining Roles)
roles.yml

[root@hftclclw0001 shield]# pwd
/etc/elasticsearch/shield
[root@hftclclw0001 shield]# ll
total 36
-rwxr-xr-x 1 elasticsearch elasticsearch 1119 Nov  9 05:21 logging.yml
-rw------- 1 elasticsearch elasticsearch 1119 Nov  9 06:28 logging.yml.new
-rwxr-xr-x 1 elasticsearch elasticsearch  473 Nov  9 05:21 role_mapping.yml
-rw------- 1 elasticsearch elasticsearch  473 Nov  9 06:28 role_mapping.yml.new
-rwxr-xr-x 1 elasticsearch elasticsearch 2634 Nov 12 09:06 roles.yml            => 角色與權限的映射
-rw------- 1 elasticsearch elasticsearch 2699 Nov  9 06:28 roles.yml.new
-rw------- 1 elasticsearch elasticsearch  128 Nov 12 08:24 system_key.new
-rwxr-xr-x 1 elasticsearch elasticsearch  410 Nov 12 09:02 users                => 用戶信息
-rw------- 1 elasticsearch elasticsearch    0 Nov  9 06:28 users.new
-rwxr-xr-x 1 elasticsearch elasticsearch   85 Nov 12 09:02 users_roles          => 用戶與角色的映射
-rw------- 1 elasticsearch elasticsearch    0 Nov  9 06:28 users_roles.new
[root@hftclclw0001 shield]# 


默認的角色有:
admin
power_user
user
...
eg1: 咱們建立一個用戶test_logstash 它只能訪問 logstash-* 的indices

1.建立角色
[root@hftclclw0001 shield]# vi /etc/elasticsearch/shield/roles.yml
...
...
logstash_user:
  cluster: all
  indices:
    'logstash-*': indices:data/read/search, indices:data/read/get, indices:admin/get   => 讀權限
...
...

2.建立用戶並執行角色
[root@hftclclw0001 shield]# /usr/share/elasticsearch/bin/shield/esusers useradd test_logstash -p test_logstash -r logstash_user
...
...

3. WEB UI 或 Terminate上校驗,是否能訪問logstash-*索引,是否能訪問寫,是否能訪問其餘的

3. LDAP 驗證


4.

相關文章
相關標籤/搜索