security-basic-setup.asciidoc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. [[security-basic-setup]]
  2. === Set up basic security for the Elastic Stack
  3. ++++
  4. <titleabbrev>Set up basic security</titleabbrev>
  5. ++++
  6. After adding password protection in the <<security-minimal-setup,minimal security configuration>>, you'll need to configure Transport Layer Security
  7. (TLS). The transport layer handles all internal communication between nodes in
  8. your cluster.
  9. The transport layer relies on mutual TLS for both encryption and
  10. authentication of nodes. Correctly applying TLS ensures that a malicious node
  11. cannot join the cluster and exchange data with other nodes. While implementing
  12. username and password authentication at the HTTP layer is useful for securing a
  13. local cluster, the security of communication between nodes requires TLS.
  14. Configuring TLS between nodes is the basic security setup to prevent
  15. unauthorized nodes from accessing to your cluster.
  16. .Understanding transport contexts
  17. ****
  18. Transport Layer Security (TLS) is the name of an industry standard protocol for
  19. applying security controls (such as encryption) to network communications. TLS
  20. is the modern name for what used to be called Secure Sockets Layer (SSL). The
  21. {es} documentation uses the terms TLS and SSL interchangeably.
  22. Transport Protocol is the name of the protocol that {es} nodes use to
  23. communicate with one another. This name is specific to {es} and distinguishes
  24. the transport port (default `9300`) from the HTTP port (default `9200`). Nodes
  25. communicate with one another using the transport port, and REST clients
  26. communicate with {es} using the HTTP port.
  27. Although the word _transport_ appears in both contexts, they mean different
  28. things. It's possible to apply TLS to both the {es} transport port and the HTTP
  29. port. We know that these overlapping terms can be confusing, so to clarify, in
  30. this scenario we're applying TLS to the {es} transport port. In
  31. <<security-basic-setup-https,the next scenario>>, we'll apply TLS to the {es}
  32. HTTP port.
  33. ****
  34. [[basic-setup-prerequisites]]
  35. ==== Prerequisites
  36. Complete the steps in <<security-minimal-setup,Minimal security for the Elastic Stack>> to enable {es} security features on every node in your cluster. You can
  37. then encrypt communications between your nodes with TLS.
  38. NOTE: You only need to create passwords for the built-in users one time for the
  39. entire cluster.
  40. [[generate-certificates]]
  41. ==== Generate the certificate authority
  42. You can add as many nodes as you want in a cluster but they must be able to
  43. communicate with each other. The communication between nodes in a cluster is
  44. handled by the transport module. To secure your cluster, you must ensure that
  45. internode communications are encrypted and verified, which is achieved with
  46. mutual TLS.
  47. In a secured cluster, {es} nodes use certificates to identify
  48. themselves when communicating with other nodes.
  49. The cluster must validate the authenticity of these certificates. The
  50. recommended approach is to trust a specific certificate authority (CA). When
  51. nodes are added to your cluster they must use a certificate signed by the same
  52. CA.
  53. For the transport layer, we recommend using a separate, dedicated CA instead
  54. of an existing, possibly shared CA so that node membership is tightly controlled. Use the `elasticsearch-certutil` tool to
  55. generate a CA for your cluster.
  56. . Use the `elasticsearch-certutil` tool to generate a CA for your cluster.
  57. +
  58. [source,shell]
  59. ----
  60. ./bin/elasticsearch-certutil ca
  61. ----
  62. a. When prompted, accept the default file name, which is `elastic-stack-ca.p12`. This file contains the public certificate for your CA and the private key used to sign certificates for each node.
  63. b. Enter a password for your CA. You can choose to leave the password blank
  64. if you're not deploying to a production environment.
  65. . Generate a certificate and private key for your node. You include the
  66. `elastic-stack-ca.p12` output file that you generated in the previous step.
  67. +
  68. [source,shell]
  69. ----
  70. ./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
  71. ----
  72. a. Enter the password for your CA, or press *Enter* if you did not configure one in the previous step.
  73. b. Create a password for the certificate and accept the default file name.
  74. +
  75. The output file is a keystore named `elastic-certificates.p12`. This file
  76. contains a node certificate, node key, and CA certificate.
  77. +
  78. `--ca <ca_file>`:: Name of the CA file used to sign your certificates. The
  79. default file name from the `elasticsearch-certutil` tool is `elastic-stack-ca.p12`.
  80. . Copy the `elastic-certificates.p12` file to the `ES_PATH_CONF`
  81. directory on every node in your cluster.
  82. *Next*: <<encrypt-internode-communication>>
  83. [[encrypt-internode-communication]]
  84. ==== Encrypt internode communications with TLS
  85. The transport networking layer is used for internal communication between
  86. nodes in a cluster. When security features are enabled, you must use TLS to
  87. ensure that communication between the nodes is encrypted.
  88. Now that you've generated a certificate authority and certificates, you'll
  89. update your cluster to use these files.
  90. NOTE: Complete the following steps for each node in your cluster. To join the
  91. same cluster, all nodes must share the same `cluster.name` value.
  92. . Open the `ES_PATH_CONF/elasticsearch.yml` file and make the following
  93. changes:
  94. a. Add the `cluster-name` setting and enter a name for your cluster:
  95. +
  96. [source,yaml]
  97. ----
  98. cluster.name: my-cluster
  99. ----
  100. b. Add the `node.name` setting and enter the name of the certificate that
  101. you generated for this node. For simplicity, it's good practice for this value
  102. to match the certificate name that you defined in your `certificates.yaml` file:
  103. +
  104. [source,yaml]
  105. ----
  106. node.name: node-1
  107. ----
  108. c. Add the following settings to enable internode communication and provide
  109. access to the node's certificate:
  110. +
  111. [source,yaml]
  112. ----
  113. xpack.security.transport.ssl.enabled: true
  114. xpack.security.transport.ssl.verification_mode: certificate
  115. xpack.security.transport.ssl.client_authentication: required
  116. xpack.security.transport.ssl.keystore.path: <node-name>.p12
  117. xpack.security.transport.ssl.truststore.path: <node-name>.p12
  118. ----
  119. . If you entered a password when creating the node certificate, run the following commands to store the password in the {es} keystore:
  120. +
  121. --
  122. [source,shell]
  123. ----
  124. ./bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
  125. ----
  126. [source,shell]
  127. ----
  128. ./bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password
  129. ----
  130. --
  131. . Complete the previous steps for each node in your cluster.
  132. . Restart {es}. The method for <<starting-elasticsearch,starting>> and <<starting-elasticsearch,stopping>> {es} varies depending on how you installed it.
  133. +
  134. For example, if you installed {es} with an archive distribution
  135. (`tar.gz` or `.zip`), you can enter `Ctrl+C` on the command line to stop
  136. {es}.
  137. +
  138. WARNING: You must perform a full cluster restart. Nodes that are configured to
  139. use TLS for transport cannot communicate with nodes that use unencrypted transport connection (and vice-versa).
  140. [[encrypting-internode-whatsnext]]
  141. ==== What's next?
  142. Congratulations! You've encrypted communications between the nodes in your
  143. cluster and can pass the
  144. <<bootstrap-checks-tls,TLS bootstrap check>>.
  145. To add another layer of security, <<security-basic-setup-https,Set up basic security for the Elastic Stack plus secured HTTPS traffic>>. In addition to
  146. configuring TLS on the transport interface of your {es} cluster, you configure
  147. TLS on the HTTP interface for both {es} and {kib}.