日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Elasticsearch开启安全认证详细步骤

發(fā)布時(shí)間:2023/12/18 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Elasticsearch开启安全认证详细步骤 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Elasticsearch開啟安全認(rèn)證詳細(xì)步驟

  • Elasticsearch開啟安全認(rèn)證詳細(xì)步驟
    • Elasticsearch搭建環(huán)境
    • 問題描述
    • 解決步驟
      • 一、生成證書:
      • 二、生成秘鑰
      • 三、將憑證遷移到指定目錄
      • 四、憑證移動(dòng)至每一臺(tái)集群下面
      • 五、修改配置文件(每一臺(tái)es都需要添加)
      • 六、在各個(gè)節(jié)點(diǎn)上添加密碼(每一臺(tái)es都需要操作)
      • 七、逐個(gè)啟動(dòng)節(jié)點(diǎn)
      • 八、設(shè)置密碼
      • 九、瀏覽器查看9200端口
      • 十、es-head訪問認(rèn)證的es

Elasticsearch開啟安全認(rèn)證詳細(xì)步驟

Elasticsearch搭建環(huán)境

Elasticsearch版本號(hào):7.3.2
服務(wù)器版本: CentOS 7.4

問題描述

項(xiàng)目等保協(xié)議掃描出了ES漏洞:檢測(cè)到ES(ElasticSearch)數(shù)據(jù)庫沒有開啟授權(quán)認(rèn)證,建議開啟授權(quán)認(rèn)證,防止非法訪問。

解決步驟

一、生成證書:

輸入./bin/elasticsearch-certutil ca

? 碰到第一個(gè)直接回車,不用管
? 碰到第二個(gè)輸入密碼,例如123456

[cjpt@localhost elasticsearch-7.3.2]$ ./bin/elasticsearch-certutil ca This tool assists you in the generation of X.509 certificates and certificate signing requests for use with SSL/TLS in the Elastic stack.The 'ca' mode generates a new 'certificate authority' This will create a new X.509 certificate and private key that can be used to sign certificate when running in 'cert' mode.Use the 'ca-dn' option if you wish to configure the 'distinguished name' of the certificate authorityBy default the 'ca' mode produces a single PKCS#12 output file which holds:* The CA certificate* The CA's private keyIf you elect to generate PEM format certificates (the -pem option), then the output will be a zip file containing individual files for the CA certificate and private keyPlease enter the desired output file [elastic-stack-ca.p12]: 【不用管,直接回車】 Enter password for elastic-stack-ca.p12 : 【輸入密碼】 [cjpt@localhost elasticsearch-7.3.2]$ ll 總用量 1888 ......(省略其他文件) -rw-------. 1 cjpt cjpt 2524 4月 19 16:28 elastic-stack-ca.p12

完成后會(huì)生成一個(gè)文件:elastic-stack-ca.p12

二、生成秘鑰

./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

? 中間需要輸入剛才設(shè)置的密碼就直接輸入就可以了,需要輸入路徑的地方不要輸入地址,就直接回車,之后會(huì)生成一個(gè)文件:elastic-certificates.p12文件

三、將憑證遷移到指定目錄

# 先創(chuàng)建目錄 mkdir ./config/certificates # 移動(dòng)憑證至指定目錄下 mv ./elastic-certificates.p12 ./config/certificates/ # 賦值權(quán)限,不然會(huì)出問題 chmod 777 ./config/certificates/elastic-certificates.p12

四、憑證移動(dòng)至每一臺(tái)集群下面

? 此處省略各種scp,就是把elastic-certificates.p12這個(gè)文件移動(dòng)到每一個(gè)es安裝目錄的相同路徑下

五、修改配置文件(每一臺(tái)es都需要添加)

vim ./config/elasticsearch.yml # 輸入如下的配置# 跨域 http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization,X-Requested-With,Content-Type,Content-Lengthxpack.security.enabled: true xpack.security.authc.accept_default_password: true xpack.security.transport.ssl.enabled: true xpack.security.transport.ssl.verification_mode: certificate xpack.security.transport.ssl.keystore.path: 【es的安裝路徑】/config/certificates/elastic-certificates.p12 xpack.security.transport.ssl.truststore.path: 【es的安裝路徑】/config/certificates/elastic-certificates.p12

六、在各個(gè)節(jié)點(diǎn)上添加密碼(每一臺(tái)es都需要操作)

./bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password

輸入密碼:第一步中設(shè)置的密碼,例如本樣例中的123456

./bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password

輸入密碼:第一步中設(shè)置的密碼,例如本樣例中的123456

七、逐個(gè)啟動(dòng)節(jié)點(diǎn)

./bin/elasticsearch -d

啟動(dòng)后看日志,是否正常,若日志異常,則需要具體排查

八、設(shè)置密碼

./bin/elasticsearch-setup-passwords interactive # 下面會(huì)要輸入很多密碼,都要自己能記住,以后要用 # 需要設(shè)置 elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user 這些用戶的密碼

九、瀏覽器查看9200端口

因?yàn)槲沂且慌_(tái)機(jī)器上裝的集群,所以使用9201端口

訪問地址為:http://【ip】:9200

輸入用戶名和密碼elastic/123456

出現(xiàn)如上結(jié)果就是成功加上認(rèn)證了

十、es-head訪問認(rèn)證的es

本來想修改es-head的源代碼的,發(fā)現(xiàn)實(shí)在改不動(dòng),只能記錄一下了

常用的es-head采用的連接為直接輸入url

但是此方法顯然不支持帶認(rèn)證的es

所以此處需要帶上賬戶名和密碼:

http://192.168.31.160:9201/?auth_user=elastic&auth_password=123456

此時(shí)再連接就可以發(fā)現(xiàn)連接正常了

總結(jié)

以上是生活随笔為你收集整理的Elasticsearch开启安全认证详细步骤的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。