search-guard 在 Elasticsearch 2.3 上的運用

uni3orns · 2016/06/23 11:09

Author:uni3orns

參考內容:

  • kibana.logstash.es/content/ela…
  • groups.google.com/forum/#!for…
  • github.com/floragunnco…

此文章基于以下軟件版本,不同版本可能略有差異:

  • elasticsearch 2.3.3
  • search-guard 2.3.3 RC1

0x00 背景


Elasticsearch是一個基于Lucene構建的開源,分布式,RESTful搜索引擎,大量使用于各種場景,隨著不斷的發展,不可避免的會產生安全問題,一些危害比較大的漏洞比如CVE-2015-3337、CVE-2015-5531。面對這些漏洞(包括0day)的威脅,以及多業務使用使用同一套es集群的情況,使用一套認證授權系統就顯得尤為必要。
經過es1代到2代產品的過度,目前主流的方案就只有官方的shield以及開源search-guard,然而我廠比較扣。

0x01 search-guard


search-guard 更新到2.x后跟 shield 配置上很相似,相比1.x的版本邏輯上更加松散。

searchguard 優點有:

  • 節點之間通過 SSL/TLS 傳輸
  • 支持 JDK SSL 和 Open SSL
  • 支持熱載入,不需要重啟服務
  • 支持 kibana4 及 logstash 的配置
  • 可以控制不同的用戶訪問不同的權限
  • 配置簡單

0x02 安裝


安裝search-guard-ssl

#!bash
sudo bin/plugin install -b com.floragunn/search-guard-ssl/2.3.3.11
復制代碼

安裝search-guard-2

#!bash
sudo bin/plugin install -b com.floragunn/search-guard-2/2.3.3.0-rc1
復制代碼

0x03 證書


根據自身情況修改官方腳本生成admin證書、node證書、根證書,將 node 證書和根證書放在 elasticsearch 配置文件目錄下,同時將admin證書和根證書放到search-guard 配置文件目錄下

tips:證書需要統一生成

0x04 配置 elasticsearch 支持 ssl


elasticsearch.yml增加以下配置:

#!bash
#############################################################################################
#                                       SEARCH GUARD                                        #
#                                       Configuration                                       #
#############################################################################################
# Add the following properties to your standard elasticsearch.yml
# (alongside with the SG SSL settings)
# This settings must always be the same on all nodes in the cluster# This defines the DNs (distinguished names) of certificates
# to which admin privileges should be assigned
security.manager.enabled: false
searchguard.authcz.admin_dn:- "CN=kirk,OU=client,O=client,l=tEst, C=De"
# kirk是administrator,可以自行修改
# This is optional
# Only needed when impersonation is used
# Allow DNs (distinguished names) to impersonate as other users
#searchguard.authcz.impersonation_dn:
#  "CN=spock,OU=client,O=client,L=Test,C=DE":
#    - worf
#  "cn=webuser,ou=IT,ou=IT,dc=company,dc=com":
#    - user2
#    - user1# Auditlog configuration:searchguard.audit.type: internal_elasticsearch
#searchguard.audit.type: external_elasticsearch
#searchguard.audit.config.http_endpoints: ['localhost:9200','localhost:9201','localhost:9202']"
#searchguard.audit.config.index: auditlog # make sure you secure this index properly
#searchguard.audit.config.type: auditlog
#searchguard.audit.config.username: auditloguser
#searchguard.audit.config.password: auditlogpassword
#searchguard.audit.config.enable_ssl: false
#searchguard.audit.config.verify_hostnames: false
#searchguard.audit.config.enable_ssl_client_auth: false# If Kerberos authentication should be used you have to configure this:# The absolute path or relative path to config/ directory
# to krb5.conf file
#searchguard.kerberos.krb5_filepath: '/etc/krb5.conf'# The absolute path or relative path to config/ directory
# to the keytab where the acceptor_principal credentials are stored.
#searchguard.kerberos.acceptor_keytab_filepath: 'eskeytab.tab'#############################################################################################
#                                     SEARCH GUARD SSL                                      #
#                                       Configuration                                       #
##########################################################################################################################################################################################
# Transport layer SSL                                                                       #
#                                                                                           #
#############################################################################################
# Enable or disable node-to-node ssl encryption (default: true)
searchguard.ssl.transport.enabled: true
# JKS or PKCS12 (default: JKS)
searchguard.ssl.transport.keystore_type: JKS
# Relative path to the keystore file (mandatory, this stores the server certificates), must be placed under the config/ dir
searchguard.ssl.transport.keystore_filepath: node-1-keystore.jks
# 當前節點的證書,根據節點名字生成
# Alias name (default: first alias which could be found)
#searchguard.ssl.transport.keystore_alias: my_alias
# Keystore password (default: changeit)
#searchguard.ssl.transport.keystore_password: changeit# JKS or PKCS12 (default: JKS)
searchguard.ssl.transport.truststore_type: JKS
# Relative path to the truststore file (mandatory, this stores the client/root certificates), must be placed under the config/ dir
searchguard.ssl.transport.truststore_filepath: truststore.jks
# Alias name (default: first alias which could be found)
#searchguard.ssl.transport.truststore_alias: my_alias
# Truststore password (default: changeit)
searchguard.ssl.transport.truststore_password: changeit
# Enforce hostname verification (default: true)
searchguard.ssl.transport.enforce_hostname_verification: true
# 如果沒有證書服務器,需要設置為false,否則無法加入集群
# If hostname verification specify if hostname should be resolved (default: true)
searchguard.ssl.transport.resolve_hostname: true
# Use native Open SSL instead of JDK SSL if available (default: true)
searchguard.ssl.transport.enable_openssl_if_available: false# Enabled SSL cipher suites for transport protocol (only Java format is supported)
# WARNING: Expert setting, do only use if you know what you are doing
# If you set wrong values here this this could be a security risk
#searchguard.ssl.transport.enabled_ciphers:
#  - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA"
#  - "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256"# Enabled SSL protocols for transport protocol (only Java format is supported)
# WARNING: Expert setting, do only use if you know what you are doing
# If you set wrong values here this this could be a security risk  
#searchguard.ssl.transport.enabled_protocols:
#  - "TLSv1.2"#############################################################################################
# HTTP/REST layer SSL                                                                       #
#                                                                                           #
#############################################################################################
# Enable or disable rest layer security - https, (default: false)
#searchguard.ssl.http.enabled: true
# JKS or PKCS12 (default: JKS)
#searchguard.ssl.http.keystore_type: PKCS12
# Relative path to the keystore file (this stores the server certificates), must be placed under the config/ dir
#searchguard.ssl.http.keystore_filepath: keystore_https_node1.jks
# Alias name (default: first alias which could be found)
#searchguard.ssl.http.keystore_alias: my_alias
# Keystore password (default: changeit)
#searchguard.ssl.http.keystore_password: changeit
# Do the clients (typically the browser or the proxy) have to authenticate themself to the http server, default is OPTIONAL
# To enforce authentication use REQUIRE, to completely disable client certificates use NONE
#searchguard.ssl.http.clientauth_mode: REQUIRE
# JKS or PKCS12 (default: JKS)
#searchguard.ssl.http.truststore_type: PKCS12
# Relative path to the truststore file (this stores the client certificates), must be placed under the config/ dir
#searchguard.ssl.http.truststore_filepath: truststore_https.jks
# Alias name (default: first alias which could be found)
#searchguard.ssl.http.truststore_alias: my_alias
# Truststore password (default: changeit)
#searchguard.ssl.http.truststore_password: changeit
# Use native Open SSL instead of JDK SSL if available (default: true)
#searchguard.ssl.http.enable_openssl_if_available: false# Enabled SSL cipher suites for http protocol (only Java format is supported)
# WARNING: Expert setting, do only use if you know what you are doing
# If you set wrong values here this this could be a security risk
#searchguard.ssl.http.enabled_ciphers:
#  - "TLS_DHE_RSA_WITH_AES_256_CBC_SHA"
#  - "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256"# Enabled SSL protocols for http protocol (only Java format is supported)
# WARNING: Expert setting, do only use if you know what you are doing
# If you set wrong values here this this could be a security risk  
#searchguard.ssl.http.enabled_protocols:
#  - “TLSv1.2"
復制代碼

重啟 elasticsearch

注意:任何修改elasticsearch.yml的操作都需要重啟elasticsearch才能生效

配置文件介紹

searchguard 主要有5個配置文件在 plugins/search-guard-2/sgconfig 下:

sg_config.yml:

  • 主配置文件不需要做改動

sg_internal_users.yml:

  • 本地用戶文件,定義用戶密碼以及對應的權限。例如:對于 ELK 我們需要一個 kibana 登錄用戶和一個 logstash 用戶:

    #!bash
    kibana4:hash: $2a$12$xZOcnwYPYQ3zIadnlQIJ0eNhX1ngwMkTN.oMwkKxoGvDVPn4/6XtO#password is: kirkroles:- kibana4
    logstash:hash: $2a$12$xZOcnwYPYQ3zIadnlQIJ0eNhX1ngwMkTN.oMwkKxoGvDVPn4/6XtOroles:- logstash
    復制代碼

密碼可用plugins/search-guard-2/tools/hash.sh生成

sg_roles.yml:

  • 權限配置文件,這里提供 kibana4 和 logstash 的權限樣例

    #!bash
    #<sg_role_name>:
    #  cluster:
    #    - '<permission>'
    #  indices:
    #    '<indexname or alias>':
    #      '<type>':  
    #        - '<permission>'
    #      _dls_: '<querydsl query>'
    #      _fls_:
    #        - '<field>'
    #        - '<field>'
    sg_kibana4:cluster:- cluster:monitor/nodes/info- cluster:monitor/healthindices:'*':'*':- indices:admin/mappings/fields/get- indices:admin/validate/query- indices:data/read/search- indices:data/read/msearch- indices:admin/get- indices:data/read/field_stats'?kibana':'*':- indices:admin/exists- indices:admin/mapping/put- indices:admin/mappings/fields/get- indices:admin/refresh- indices:admin/validate/query- indices:data/read/get
    sg_logstash:cluster:- indices:admin/template/get- indices:admin/template/putindices:'logstash-*':'*':- WRITE- indices:data/write/bulk- indices:data/write/delete- indices:data/write/update- indices:data/read/search- indices:data/read/scroll- CREATE_INDEX
    復制代碼

sg_roles_mapping.yml:

  • 定義用戶的映射關系,添加 kibana 及 logstash 用戶對應的映射:

    #!bash
    sg_logstash:users:- logstash
    sg_kibana4:backendroles:- kibanausers:- kibana4
    復制代碼

sg_action_groups.yml:

  • 定義權限

加載配置并啟用

#!bash
sh plugins/search-guard-2/tools/sgadmin.sh -cn 集群名稱(默認為elasticsearch,修改名稱必須添加此參數) -h 127.0.0.1 -cd plugins/search-guard-2/sgconfig -ks plugins/search-guard-2/sgconfig/kirk-keystore.jks -kspass kspass -ts plugins/search-guard-2/sgconfig/truststore.jks  -tspass tspass -nhnv
復制代碼

如修改了searchguard,則需要重新加載配置執行

注意:search-guard配置的相關改動不需要重啟elasticsearch,相關的配置實際上存儲在searchguard 的indice下了

至此大家就可以安全的使用elasticsearch

關于ldap以及https的配置將在下一篇給出

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/255264.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/255264.shtml
英文地址,請注明出處:http://en.pswp.cn/news/255264.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

HALCON示例程序class_2dim_sup.hdev使用二維像素分類對圖像進行分割

HALCON示例程序class_2dim_sup.hdev使用二維像素分類對圖像進行分割 示例程序源碼&#xff08;加注釋&#xff09; 定義Interactive并賦值&#xff0c;0&#xff1a;固定框&#xff1b;1&#xff1a;手工繪制框。 Interactive : 0 讀入圖片 read_image (Image, ‘ic’) 關閉…

sys

sys.argv 命令行參數List&#xff0c;第一個元素是程序本身路徑 sys.exit(n) 退出程序&#xff0c;正常退出時exit(0) sys.version 獲取Python解釋程序的版本信息 sys.maxint 最大的Int值 sys.path 返回模塊的搜索路徑&#xff0c;初…

修改環境變量

在path變量后添加&#xff0c;對變量長度無限制&#xff0c;需要重啟后生效reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_SZ /d "%path%;c:\newpath;whatever" /freg save "HKLM\SYSTEM\CurrentCont…

Canny邊緣檢測算法原理及其VC實現詳解(二)

3、 Canny算法的實現流程 由于本文主要目的在于學習和實現算法&#xff0c;而對于圖像讀取、視頻獲取等內容不進行闡述。因此選用OpenCV算法庫作為其他功能的實現途徑&#xff08;關于OpenCV的使用&#xff0c;作者將另文表述&#xff09;。首先展現本文將要處理的彩色圖片。 …

IDEA注冊jar包使用和常用插件

IDEA注冊jar包使用 點擊獲取下載地址或生成注冊碼 一、安裝完成后&#xff0c;先不啟動&#xff0c;首先如下圖修改相關的地方。 二、啟動IDEA&#xff0c;并且激活IDEA IDEA插件倉庫 IntelliJ IDEA Plugins 一、Maven Helper 我一般用這款插件來查看maven的依賴樹。在不使用此…

HALCON示例程序class_2dim_unsup.hdev基于二維直方圖的聚類分類

HALCON示例程序class_2dim_unsup.hdev基于二維直方圖聚類分類的顏色分類 示例程序源碼&#xff08;加注釋&#xff09; 讀入圖片 read_image (Image, ‘patras’)關閉窗口 dev_close_window ()得到圖片尺寸大小 get_image_size (Image, Width, Height)打開窗口 dev_open_wind…

Android Monkey壓力測試

一. JAVA環境的搭建 安裝jdk-8u151-windows-x64,可以到官網或者應用中心下載.JAVA環境變量的搭建: 在"我的電腦"-"屬性"-"高級"-"環境變量"中,點擊新建,填寫變量名為JAVA_HOME,變量值為JAVA安裝的路徑.在系統變量中找到Path,點擊編輯,…

bzoj 4517: [Sdoi2016]排列計數

4517: [Sdoi2016]排列計數 Time Limit: 60 Sec Memory Limit: 128 MBSubmit: 637 Solved: 396[Submit][Status][Discuss]Description 求有多少種長度為 n 的序列 A&#xff0c;滿足以下條件&#xff1a;1 ~ n 這 n 個數在序列中各出現了一次若第 i 個數 A[i] 的值為 i&#x…

idea compare功能 之一次bug修復

一次bug修復 最近開發完了一套單點系統&#xff0c;jenkins打包上傳到服務器就出問題&#xff0c; 可以啟動但是不能正常工作。 首先想到的是環境不一樣&#xff0c; 于是把jenkins的jdk和maven都調整和本機大版本相同。 當然肯定是沒卵用的&#xff0c; 于是查看日志 Class pa…

黑白CCD成像不理想,如何補色

黑白CCD成像不理想&#xff0c;如何補色

HALCON示例程序class_ndim_box.hdev基于多通道圖像的分類

HALCON示例程序class_ndim_box.hdev基于多通道圖像的分類 示例程序源碼&#xff08;加注釋&#xff09; 讀入圖片 read_image (Image, ‘ic’)創建一個新的分類器 create_class_box (ClassifHandle)獲取圖片大小 get_image_size (Image, Width, Height)關閉窗口 dev_close_wi…

gcc編譯系統

一、 C語言編譯過程 C語言的編譯過程可分為四個階段&#xff1a; 1、預處理&#xff08;Preprocessing&#xff09; 對源程序中的偽指令&#xff08;即以#開頭的指令&#xff09;和特殊符號進行處理的過程。 偽指令包括&#xff1a;1&#xff09;宏定義指令&#xff1b; 2&…

自制反匯編逆向分析工具 迭代第六版本 (五)

本工具從最初版的跳轉分布圖只為了更直觀地分析反匯編代碼的分支結構&#xff0c;第三版開始對直觀圖進行逆向分支代碼的輸出&#xff0c;第四版對分支輸出策略的一些探索&#xff0c;第五版結合之前的探索進行改進。第六版在現在功能的基礎上進行增強&#xff0c;利用第六版&a…

模型搜索 及 輪廓搜索 的原理

模型搜索 及 輪廓搜索 的原理

Linux中設置vim自動在運算符號兩邊加上空格

vim中設置自動在-之類的運算符號左右兩邊加上空格。原版的vim不帶這個功能&#xff0c;寫出的代碼例如zxy&#xff0c;不美觀&#xff0c;很多編譯器&#xff08;如VS&#xff09;能夠自動在符號兩邊加上空格&#xff0c;如z x y&#xff0c;看起來比較美觀。 只要在.vimrc里…

HALCON示例程序class_ndim_norm.hdev基于多通道圖像的分類

HALCON示例程序class_ndim_norm.hdev基于多通道圖像的分類 示例程序源碼&#xff08;加注釋&#xff09; 讀入圖片 read_image (Image, ‘ic’)得到圖片大小 get_image_size (Image, Width, Height)關閉窗口 dev_close_window ()根據圖片大小打開窗口 dev_open_window (0, 0,…

centos7搭建FTP服務器

1.   使用 yum 安裝 vsftpd&#xff1a;yum install -y vsftpd 2.  啟動 VSFTPD&#xff1a;systemctl start vsftpd.service 3.  啟動后可監聽到21端口&#xff1a;netstat -nltp | grep 21 4.  配置FTP權限&#xff1a;&#xff08;vsftpd.conf&#xff0c;修改前先備…

[HDOJ2586]How far away?(最近公共祖先, 離線tarjan, 并查集)

題目鏈接&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid2586 這題以前做過…現在用tarjan搞一發…竟然比以前暴力過的慢………… 由于是離線算法&#xff0c;需要Query來保存查詢數據&#xff0c;Ans來保存結果。最后輸出的時候按照idx的順序輸出&#xff0c;所以胡搞…

愛普生SCARA機器人參考文檔列表

愛普生SCARA機器人參考文檔列表軟件EPSON RC 5.0 用戶指南記載了機器人系統與程序開發軟件。 - 安全 - 機器人系統的操作與設定 - 程序開發軟件 EPSON RC GUI的操作 - SPEL語言、應用程序 - 機器人…

HALCON示例程序classify_citrus_fruits.hdev應用常規gmm分類器進行水果分類

HALCON示例程序classify_citrus_fruits.hdev應用常規gmm分類器進行水果分類 示例程序源碼&#xff08;加注釋&#xff09; 讀入圖片、顯示與顯示相關設置 read_image (Image, ‘color/citrus_fruits_01’) get_image_pointer1 (Image, Pointer, Type, Width, Height) dev_clos…