安装SearchGuard插件
集群中每一台设备都需要安装<
在线安装
<b>在"http://mvnrepository.com/artifact/com.floragunn/search-guard-5"中查找相应版本。
Example(com.floragunn:search-guard-5:5.0.1-12)</b>
$ cd %ES_HOME%
$ bin/elasticsearch_plugin install -b com.floragunn:search-guard-"version":"version"
离线安装
<b>在"http://mvnrepository.com/artifact/com.floragunn/search-guard-5"下载相应版本的search-guard插件。
Example(file:////root/Desktop/search-guard.zip)</b>
$ cd %ES_HOME%
$ bin/elasticsearch_plugin install -b file:///path/search-guard.zip
安装SearchGuardSSL
下载地址
https://github.com/floragunncom/search-guard-ssl
进行安装
<b>1.根据<font color=green size=4 face="黑体">example基本配置详解</font>配置example.sh</b>
$ cd %search-guard%/example-pki-scripts
$ vim example.sh
<b>2.运行 example.sh (<font color=red size=3 face="黑体">集群中任意一台设备运行即可</font>)并把 trustore.jks node-<font color=red size=3 face="黑体">x</font>-keystore.jks(<font color=red size=3 face="黑体">x代表node-number,需要放到集群中相应node的设备中</font>) 这两个文件放到ES用户有访问权限的目录下,这里放到config下方便配置</b>
$ ./example.sh
$ cp truststore.jks node-1-keystore.jks %ES_HOME%/config/
<b>3.据<font color=green size=4 face="黑体">elasticsearch配置详解</font>配置 config/elasticsearch.yml</b>
$ cd %ES_HOME%
$ vim config/elasticsearch.yml
<b>4.重启elasticsearch后,elasticsearch之间的连接已经是加密的了,但因为没有初始化SearchGuard索引,会出现如下报错。</b>
$ Not yet initialized (you may need to run sgadmin)
<b>5.初始化SearchGuard索引, 根据<font color=green size=4 face="黑体">elasticsearch配置详解</font>配置 config/elasticsearch.yml,并运行sgadmin.sh (<font color=red size=3 face="黑体">集群中任意一台设备运行即可</font>)</b>
$ cd %ES_HOME%/
$ vim config/elasticsearch.yml
$ cd %search-guard%/example-pki-scripts
$ cp cn_name-keystore.jks %ES_HOME%/plugins/search-guard-5/sgconfig/
$ cd %ES_HOME%/plugins/search-guard-5/sgconfig/
$ tools/sgadmin.sh \
> -ts %ES_HOME%/config/trustore.jks \
> -tspass tspass \
> -ks sgconfig/cn_name-keystore.jks \
> -kspass kspass \
> -cd sgconfig/ \
> -icl -nhnv -h localhost
<b>6.配置用户密码,使用hash.sh对新密码进行加密,并将加密的数据更新至sg_internet_users.yml,再次初始化SearchGuard索引</b>
$ cd %ES_HOME%/plugins
$ tools/hash.sh
$ vim sgconfig/sg_internet_users.yml
$ tools/sgadmin.sh \
> -ts %ES_HOME%/config/trustore.jks \
> -tspass tspass \
> -ks sgconfig/cn_name-keystore.jks \
> -kspass kspass \
> -cd sgconfig/ \
> -icl -nhnv -h localhost
example.sh 基本配置详解
./gen_root_ca.sh capass tspass
$1 为CA_PASS,即CA密码(根证书密码, 可自定义)
$2 为TS_PASS,即TS密码(truststore,信任证书密码, 可自定义)
./gen_node_cert.sh 1 kspass capass
$1 为node编号,生成证书后的文件名为node-1*
$2 为KS_PASS,即KS密码(keystore文件密码,可自定义)
$3 为CA_PASS,即CA密码(根证书密码,可自定义)
./gen_client_node_cert.sh cn_name kspass capass
$1 为客户端节点名称,生成证书后的文件名为test* ,可自定义
$2 为KS_PASS,即KS密码(keystore文件密码, 可自定义)
$3 为CA_PASS,即CA密码(根证书密码,可自定义)
elasticsearch配置详解
# 配置ssl,让elasticsearch使用tls加密通讯
searchguard.ssl.transport.enabled: true
searchguard.ssl.transport.keystore_filepath: node-0-keystore.jks
searchguard.ssl.transport.keystore_password: kspass
searchguard.ssl.transport.truststore_filepath: truststore.jks
searchguard.ssl.transport.truststore_password: tspass
searchguard.ssl.transport.enforce_hostname_verification: false
searchguard.ssl.transport.resolve_hostname: false
# 配置 SeachGuard 初始化
searchguard.authcz.admin_dn:
- CN=cn_name, OU=client, O=client, L=Test, C=DE # 此处的 CN 为 gen_client_node_cert.sh 的 $1
# http配置,这里我只是为了测试方便,配置完,应该设置为true
searchguard.ssl.http.enabled: false
searchguard.ssl.http.keystore_filepath: node-0-keystore.jks
searchguard.ssl.http.keystore_password: kspass
searchguard.ssl.http.truststore_filepath: truststore.jks
searchguard.ssl.http.truststore_password: tspass
searchguard.allow_all_from_loopback: true