es7.9開啟認(rèn)證

證書生成工具(elasticsearch-certutil)

支持4種模式生成證書蔗包,下面以CA模式為例蒙保,
其他模式可參考https://blog.csdn.net/yi_qingjun/article/details/128742669

[root@ip elasticsearch]# bin/elasticsearch-certutil -h
Simplifies certificate creation for use with the Elastic Stack

Commands
--------
csr - generate certificate signing requests
cert - generate X.509 certificates and keys
ca - generate a new local certificate authority
http - generate a new certificate (or certificate request) for the Elasticsearch HTTP interface

Non-option arguments:
command              

Option             Description        
------             -----------        
-E <KeyValuePair>  Configure a setting
-h, --help         Show help          
-s, --silent       Show minimal output
-v, --verbose      Show verbose output

生成CA證書

[root@ip elasticsearch]# bin/elasticsearch-certutil ca

生成p12密鑰

[root@ip elasticsearch]# bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

新增配置

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
##默認(rèn)讀config目錄下你稚,需要移動(dòng)文件且賦權(quán)
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

verification_mode配置方式支持三種:
full,認(rèn)證證書是否通過信任的CA證書簽發(fā),同時(shí)認(rèn)證server的hostname 或者 IP 地址是否匹配證書中配置的
cretificate屉符,只認(rèn)證證書是否通過信任的CA證書簽發(fā)的
none篷角,什么也不認(rèn)證,相當(dāng)于關(guān)閉了SSL/TLS認(rèn)證冶伞,僅用于你非常相信的安全的環(huán)境

默認(rèn)情況下新症,elasticsearch-certutil生成的證書中沒有主機(jī)名信息。這意味著可以為集群中的任意節(jié)點(diǎn)使用此證書响禽,但是必須關(guān)閉主機(jī)名驗(yàn)證徒爹。

如果設(shè)置密碼,需要給各節(jié)點(diǎn)加上密碼

./bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
1輸入密碼:創(chuàng)建p12秘鑰設(shè)置的密碼(不是其他文章中提到的CAS罄唷B⌒帷!)侯繁,例如本樣例中的123456
./bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password
1輸入密碼:創(chuàng)建p12秘鑰設(shè)置的密碼(不是其他文章中提到的CAE衷!V埂)丽焊,例如本樣例中的123456

重啟es集群

設(shè)置用戶密碼

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

docker-compose啟動(dòng)添加kibana環(huán)境變量

      - ELASTICSEARCH_HOSTS=["http://ip:9200","http://ip:19200","http://ip:29200"]
      - ELASTICSEARCH_USERNAME="kibana"
      - ELASTICSEARCH_PASSWORD="123456"

至此完成es集群內(nèi)部安全通信技健,即9300端口通信加密

開啟es集群外部安全通信写穴,即9200端口通信加密

##新增配置
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.verification_mode: certificate
xpack.security.http.ssl.keystore.path: elastic-certificates.p12
xpack.security.http.ssl.truststore.path: elastic-certificates.p12

如果設(shè)置密碼,需要給各節(jié)點(diǎn)加上密碼

./bin/elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
1輸入密碼:創(chuàng)建p12秘鑰設(shè)置的密碼(不是其他文章中提到的CA4萍0∷汀!)帽芽,例如本樣例中的123456
./bin/elasticsearch-keystore add xpack.security.http.ssl.truststore.secure_password
1輸入密碼:創(chuàng)建p12秘鑰設(shè)置的密碼(不是其他文章中提到的CAI鞠啤!5冀帧)披泪,例如本樣例中的123456

重啟es集群

現(xiàn)在需要通過https方式訪問

kibana相關(guān)配置

為kibana訪問es進(jìn)行配置(給kinbana生成pem)

[root@ip config]# openssl pkcs12 -in elastic-certificates.p12 -cacerts -nokeys -out elastic-ca.pem
Enter Import Password:p12秘鑰密碼
MAC verified OK

配置kibana

##需要賦權(quán)pem文件
elasticsearch.ssl.certificateAuthorities: [ "/usr/share/kibana/config/elastic-ca.pem" ]
elasticsearch.ssl.verificationMode: certificate

為kibana配置https,生成elastic-stack-ca.zip

[root@ip- elasticsearch]# bin/elasticsearch-certutil ca --pem
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 authority

By default the 'ca' mode produces a single PKCS#12 output file which holds:
    * The CA certificate
    * The CA's private key

If 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 key

Please enter the desired output file [elastic-stack-ca.zip]: 

對(duì)生成的elastic-stack-ca.zip進(jìn)行解壓搬瑰,生成ca.crt 和 ca.key

配置kibana

##需要賦權(quán)
server.ssl.enabled: true
server.ssl.certificate: config/ca.crt
server.ssl.key: config/ca.key
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末款票,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子泽论,更是在濱河造成了極大的恐慌艾少,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,198評(píng)論 6 514
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件翼悴,死亡現(xiàn)場(chǎng)離奇詭異缚够,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)鹦赎,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,334評(píng)論 3 398
  • 文/潘曉璐 我一進(jìn)店門谍椅,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人古话,你說我怎么就攤上這事雏吭。” “怎么了陪踩?”我有些...
    開封第一講書人閱讀 167,643評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵杖们,是天一觀的道長。 經(jīng)常有香客問我肩狂,道長摘完,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,495評(píng)論 1 296
  • 正文 為了忘掉前任傻谁,我火速辦了婚禮描焰,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己荆秦,他們只是感情好篱竭,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,502評(píng)論 6 397
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著步绸,像睡著了一般掺逼。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上瓤介,一...
    開封第一講書人閱讀 52,156評(píng)論 1 308
  • 那天吕喘,我揣著相機(jī)與錄音,去河邊找鬼刑桑。 笑死氯质,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的祠斧。 我是一名探鬼主播闻察,決...
    沈念sama閱讀 40,743評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼琢锋!你這毒婦竟也來了辕漂?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,659評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤吴超,失蹤者是張志新(化名)和其女友劉穎钉嘹,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體鲸阻,經(jīng)...
    沈念sama閱讀 46,200評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡跋涣,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,282評(píng)論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了鸟悴。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片陈辱。...
    茶點(diǎn)故事閱讀 40,424評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖遣臼,靈堂內(nèi)的尸體忽然破棺而出性置,到底是詐尸還是另有隱情拾并,我是刑警寧澤揍堰,帶...
    沈念sama閱讀 36,107評(píng)論 5 349
  • 正文 年R本政府宣布,位于F島的核電站嗅义,受9級(jí)特大地震影響屏歹,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜之碗,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,789評(píng)論 3 333
  • 文/蒙蒙 一蝙眶、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦幽纷、人聲如沸式塌。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,264評(píng)論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽峰尝。三九已至,卻和暖如春收恢,著一層夾襖步出監(jiān)牢的瞬間武学,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,390評(píng)論 1 271
  • 我被黑心中介騙來泰國打工伦意, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留火窒,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,798評(píng)論 3 376
  • 正文 我出身青樓驮肉,卻偏偏與公主長得像熏矿,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子缆八,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,435評(píng)論 2 359