伸縮性:ElasticsearchへのスタートのHTTPSアクセス

今日の記事では、我々は我々のElasticsearchがhttpsサービスを開始ようにする方法を説明します。多くの場合、これは非常に便利です。特にセキュリティ弾性SIEMの領域に、我々はそう我々のデータは、より安全で信頼性の高い作り、Elasticsearch訪問HTTPSアクセスしていなければなりません。

 

インストール弾性スタック

「まず第一に、私たちは前の記事従うことができます:弾性新人スタートガイド ElasticsearchとKibanaをインストールする」を。私たちはElasticsearchとKibanaをインストールしたら、私たちはしていたローカルホスト:9200はlocalhost:5601私たちが望むの出力を参照してください。

 

安全Elasticsearchを有効にするには

「私たちは、私の以前の記事従うことができます:弾性アカウントのセキュリティ設定をelasticsearch当社Elasticsearchのセキュリティを設定する」を。私達はちょうど弾性デフォルトのスーパーユーザーを使用し、新しいユーザーを作成することはできません。

我々は上記の設定を設定すると、我々はKibanaを起動したとき、それは、ログインするためのユーザー名とパスワードを入力するように私たちを必要とします。あなたは上の写真を見てきた場合、それは私たちのセキュリティアカウントの設定が成功していることを意味します。

 

P12の生産証明書

我々はリンク「を参照することができます生成する証明書 Elasticsearchのインストールディレクトリにある」、次のコマンドを使用します。

./bin/elasticsearch-certutil ca
$ pwd
/Users/liuxg/elastic9/elasticsearch-7.6.0
liuxg:elasticsearch-7.6.0 liuxg$ ./bin/elasticsearch-certutil ca
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.bouncycastle.jcajce.provider.drbg.DRBG (file:/Users/liuxg/elastic9/elasticsearch-7.6.0/lib/tools/security-cli/bcprov-jdk15on-1.61.jar) to constructor sun.security.provider.Sun()
WARNING: Please consider reporting this to the maintainers of org.bouncycastle.jcajce.provider.drbg.DRBG
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
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.p12]: 
Enter password for elastic-stack-ca.p12 : 

私たちは、デフォルトのファイル名を受け入れ、そしておなじみのパスワードを入力の上では(私の場合のために、私は空の受け入れ)。Elasticsearchのインストールディレクトリに我々は、我々は生産証明書ファイルを見ることができます:

$ ls
LICENSE.txt          config               lib
NOTICE.txt           data                 logs
README.asciidoc      elastic-stack-ca.p12 modules
bin                  jdk.app              plugins

私たちは、証明書を生成するには、次のコマンドを実行します。

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

上記のコマンドは、証明書弾性certificates.p12を生成するために、私たちのCAを使用します。

$ pwd
/Users/liuxg/elastic9/elasticsearch-7.6.0
liuxg:elasticsearch-7.6.0 liuxg$ ls
LICENSE.txt              data                     logs
NOTICE.txt               elastic-certificates.p12 modules
README.asciidoc          elastic-stack-ca.p12     plugins
bin                      jdk.app
config                   lib

私たちは、Elasticsearchのインストールディレクトリの下のconfigサブディレクトリにコピーする弾性certificates.p12証明書の上に置きます。

$ pwd
/Users/liuxg/elastic9/elasticsearch-7.6.0
liuxg:elasticsearch-7.6.0 liuxg$ ls config/
elastic-certificates.p12 jvm.options              roles.yml
elasticsearch.keystore   log4j2.properties        users
elasticsearch.yml        role_mapping.yml         users_roles

 

私たちは、次のコマンドを使用します。

openssl pkcs12 -in elastic-stack-ca.p12 -out newfile.crt.pem -clcerts -nokeys

それはnewfile.crt.pemと呼ばれるファイルを生成します。私たちは、Kibanaのインストールディレクトリの下のconfigサブディレクトリにこのファイルをcopyed:

$ pwd
/Users/liuxg/elastic9/kibana-7.6.0-darwin-x86_64
liuxg:kibana-7.6.0-darwin-x86_64 liuxg$ ls config/
apm.js                   kibana.yml
elastic-certificates.p12 newfile.crt.pem

 

設定Elasticsearch

私たちのconfig / elasticsearch.ymlの次Elasticsearch構成。私たちは、弾性公式文書「を参照してくださいelasticsearchで暗号化通信を、我々は、以下の設定を追加します、」:

xpack.security.transport.ssl.enabled: true
xpack.security.http.ssl.enabled: true
xpack.security.authc.api_key.enabled: true
xpack.security.http.ssl.keystore.path: /Users/liuxg/elastic9/elasticsearch-7.6.0/config/elastic-certificates.p12
xpack.security.http.ssl.truststore.path: /Users/liuxg/elastic9/elasticsearch-7.6.0/config/elastic-certificates.p12

私たちは、Elasticsearchを再起動します。

./bin/elasticsearch

だから、私たちのElasticsearchが正常にHTTPSモードで実行していること。我々は内のアドレスを入力し、クロムHTTPS:// localhostを:9200、私たちが見ることができます:

明らかに、我々はもはや以前のように9200のローカルアドレスにアクセスすることはできません。上記の画面が表示されたら、我々は(現在のクロムウィンドウの場合)次の文字列を入力します。

thissisunsafe

我々が設定する前に私たちは、「クリックし、弾性およびパスワードにElasticsearch でのサイン」:

 

私たちは、正しい時刻当社Elasticsearchのインストール、上から見ることができます。

また、開くためにSafariブラウザを使用することができます。

私たちはをクリックして[詳細の表示ボタン:

私たちをクリックして訪問このウェブサイトのリンク:

以上のように、セキュリティアカウント名とパスワード弾性を作成する際に、我々は、ユーザを入力する前に、我々はElasticsearchにアクセスすることができます。

我々はポストマンを使用している場合、我々は避けるために、検査の証明書の中の「設定」を通じて、以下の構成を行うことができます。

 

 

私たちは、SSL証明書の検証の最上部にあるスイッチをオフにします。

上記の設定後、我々はElasticsearchはポストマンにHTTPSを持ってアクセスすることができます。どのようにアクセスElasticsearchへの郵便配達は、私の以前の記事を参照してください「伸縮性:アクセスへの郵便配達使用スタック弾性。」

 

配置Kibana

首尾httpsでElasticsearchにアクセスするために私たちのKibanaができるようにするために。我々はまた、適切な設定を行う必要があります。私たちは、設定/ kibana.yml開きます。次の設定を追加します。

elasticsearch.hosts: ["https://localhost:9200"]
elasticsearch.ssl.certificateAuthorities: ["/Users/liuxg/elastic9/kibana-7.6.0-darwin-x86_64/config/newfile.crt.pem"]
elasticsearch.ssl.verificationMode: none

私たちは、パスの先頭に満たされ、以前に生成された証明書のnewfile.crt.pemの上に置いて、我々は簡単にアクセスすることができるようにするために、我々はkibanaためverificationModeを有効にしないでください。

我々は設定を終了したら、我々はkibanaを再起動します。

私たちは、弾性、ユーザーのパスワードを入力し、我々はKibanaにインターフェイスを入力できます。

上記において、我々は、我々が正常にインターフェースのKibanaを締結していることがわかります。

 

Elasticsearchにhttpsに入ってくるデータを打ちます

HTTPSの導入以来、その後、どのように我々はそれにElasticsearchに私たちの受信データを置けばいいの?データをインポートするとき、私たちは、コンフィギュレーション・ファイルのビートに証明書を設定する必要があります。ここでは、例をfilebeatする必要があります。私たちは、Elasticsearchインストールディレクトリは、次のコマンドを入力します。

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

上記のコマンドは、いわゆる「certificate-bundle.zip」ファイルを生成します。

$ pwd
/Users/liuxg/elastic9/elasticsearch-7.6.0
liuxg:elasticsearch-7.6.0 liuxg$ ls
LICENSE.txt            certificate-bundle.zip lib
NOTICE.txt             config                 logs
README.asciidoc        data                   modules
bin                    jdk.app                plugins

私たちは、解凍にファイルを入れて、内側に置くことができca.crtを filebeatインストールサブディレクトリを抽出すること。

この方法の一つ

オープンfilebeatプロファイルfilebeat.yml、および証明書の情報を追加します。

filebeat.yml

output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["localhost:9200"]

  # Protocol - either `http` (default) or `https`.
  protocol: "https"

  # Authentication credentials - either API key or username/password.
  #api_key: "id:api_key"
  username: "elastic"
  password: "123456"
  ssl.certificate_authorities: ["/Users/liuxg/elastic9/filebeat-7.6.0-darwin-x86_64/ca.crt"]
  ssl.verification_mode: none

上記では、あなたのユーザ名とパスワード、並びにこれらの証明書パス上のパスを交換する必要性を記入する必要があります。

方法二

我々はまた、次のコマンドを実行して、独自の証明書を生成することができます。Elasticsearchのインストールディレクトリにある私たちは、前提として上記弾性スタックca.p12で生成された、次のコマンドを実行します。

openssl pkcs12 -in elastic-stack-ca.p12 -out newfile.crt.pem -clcerts -nokeys

上記のコマンドは、のnewfile.crt.pemと呼ばれるファイルを生成します。私たちは、インストールディレクトリのfilebeatにこのファイルをコピーして、次のように私たちのfilebeat.ymlを変更します。

output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["localhost:9200"]

  # Protocol - either `http` (default) or `https`.
  protocol: "https"

  # Authentication credentials - either API key or username/password.
  #api_key: "id:api_key"
  username: "elastic"
  password: "123456"
  ssl.certificate_authorities: ["/Users/liuxg/elastic9/filebeat-7.6.0-darwin-x86_64/newfile.crt.pem"]
  ssl.verification_mode: none

ファイル名を指定して実行Filebeat

上記の構成を変更した後、我々はシステムモジュールを起動します。

./filebeat modules enable system
./filebeat setup
$ ./filebeat setup
Overwriting ILM policy is disabled. Set `setup.ilm.overwrite:true` for enabling.

Index setup finished.
Loading dashboards (Kibana must be running and reachable)
Loaded dashboards
Setting up ML using setup --machine-learning is going to be removed in 8.0.0. Please use the ML app instead.
See more: https://www.elastic.co/guide/en/elastic-stack-overview/current/xpack-ml.html
Loaded machine learning job configurations
Loaded Ingest pipelines

私たちは、次のコマンドによってfilebeatを実行できます。

./filebeat -e

私たちは、Kibanaを開きます。

[Filebeatシステム]のSyslogのダッシュボードECSの上にクリックしてください:

私たちは、filebeat成功しElasticsearchのデータに渡さ見ることができます。

参考:

【1】https://www.elastic.co/guide/en/elasticsearch/reference/master/configuring-tls.html

【2】https://www.elastic.co/guide/en/elasticsearch/reference/current/encrypting-communications-certificates.html

【3】https://www.elastic.co/blog/how-to-setup-tls-for-elasticsearch-kibana-logstash-filebeat-with-offline-install-in-linux

 

 

发布了517 篇原创文章 · 获赞 126 · 访问量 91万+

おすすめ

転載: blog.csdn.net/UbuntuTouch/article/details/105044365