2. Installing OpenDistro for Elasticsearch Plugins
The Opendistro allows us to add plugins to our elastic stack, in particular the security plugin which will allow us to secure our stack and add further features like users and roles management, the alerting plugins which will allow us to create rules and send alerts via slack, webhooks and lately they added Email.
If you are using a cluster of nodes installing a plugin would only be successfully operational if it is installed on all nodes.
Further information about Opendistro plugins can be found here
We are running 7.8.0 so the compatible opendistro plugin version is 1.9.0.0
Disable XPACK security
First lets disable xpack security on both Elasticsearch and Kibana and add this line to their configuration files
xpack.security.enabled:false
Installing Security plugin for Elasticsearch
Navigate to the Elasticsearch home directory (most likely, it is /usr/share/elasticsearch), and run the install command for each plugin.
After installing the modules we must restart Elasticsearch and Kibana to take into account the installed plugins but before restarting them we must run the following script to generate the default certificates of opendistro
If you have a cluster, this step must be done on all Elasticsearch instances before restarting the Elasticsearch service
Generating our own certificates is not within the scope of this blog. so make sure you modify these certificates before putting this on production.
After restart you would notice some changes to Elasticsearch configuration file.
######## Start OpenDistro for Elasticsearch Security Demo Configuration ######### WARNING: revise all the lines below before you go into productionopendistro_security.ssl.transport.pemcert_filepath:esnode.pemopendistro_security.ssl.transport.pemkey_filepath:esnode-key.pemopendistro_security.ssl.transport.pemtrustedcas_filepath:root-ca.pemopendistro_security.ssl.transport.enforce_hostname_verification:falseopendistro_security.ssl.http.enabled:trueopendistro_security.ssl.http.pemcert_filepath:esnode.pemopendistro_security.ssl.http.pemkey_filepath:esnode-key.pemopendistro_security.ssl.http.pemtrustedcas_filepath:root-ca.pemopendistro_security.allow_unsafe_democertificates:trueopendistro_security.allow_default_init_securityindex:trueopendistro_security.authcz.admin_dn: - CN=kirk,OU=client,O=client,L=test, C=deopendistro_security.audit.type:internal_elasticsearchopendistro_security.enable_snapshot_restore_privilege:trueopendistro_security.check_snapshot_restore_write_privileges:trueopendistro_security.restapi.roles_enabled: ["all_access","security_rest_api_access"]cluster.routing.allocation.disk.threshold_enabled:falsenode.max_local_storage_nodes:3######## End OpenDistro for Elasticsearch Security Demo Configuration ########
Changing Logstash and Kibana's configuration
Since we installed security plugin all communication now to our node is in https so we need to change their configurations accordingly.
Copy demo certificates to accessible locations for kibana and logstash and change, if necessary, the owner and group of the files.
server.port:5601server.host:"192.168.20.222"server.name:"elk-allinone"elasticsearch.hosts: ["https://localhost:9200"]######### for demo purposes I am using the same user admin but you can create a dedicated user for communications between kibana and elasticsearch
elasticsearch.username:"admin"elasticsearch.password:"admin"xpack.security.enabled:false######### Enable SSL #################”server.ssl.enabled:trueserver.ssl.certificate:/etc/kibana/esnode.pemserver.ssl.key:/etc/kibana/esnode-key.pemelasticsearch.ssl.certificateAuthorities: [ "/etc/kibana/root-ca.pem" ]elasticsearch.ssl.verificationMode:certificate