security-minimal-setup.asciidoc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. [[security-minimal-setup]]
  2. === Set up minimal security for {es}
  3. ++++
  4. <titleabbrev>Set up minimal security</titleabbrev>
  5. ++++
  6. IMPORTANT: You only need to complete the following steps if you're running an
  7. existing, unsecured cluster and want to enable the {es} {security-features}.
  8. In {es} 8.0 and later, security is
  9. <<configuring-stack-security,enabled automatically>> when you start {es} for the
  10. first time.
  11. If you're running an existing {es} cluster where security is disabled, you can
  12. manually enable the {es} {security-features} and then create passwords for
  13. built-in users. You can add more users later, but using the built-in users
  14. simplifies the process of enabling security for your cluster.
  15. include::../security-manual-configuration.asciidoc[tag=minimal-security-note]
  16. ==== Enable {es} security features
  17. Enabling the {es} security features provides basic authentication so
  18. that you can run a local cluster with username and password authentication.
  19. . On *every* node in your cluster, stop both {kib} and {es} if they are running.
  20. . On *every* node in your cluster, add the `xpack.security.enabled` setting to
  21. the `$ES_PATH_CONF/elasticsearch.yml` file and set the value to `true`:
  22. +
  23. [source,yaml]
  24. ----
  25. xpack.security.enabled: true
  26. ----
  27. +
  28. NOTE: The `$ES_PATH_CONF` variable is the path for the {es}
  29. configuration files. If you installed {es} using archive distributions
  30. (`zip` or `tar.gz`), the variable defaults to `$ES_HOME/config`. If you used
  31. package distributions (Debian or RPM), the variable defaults to `/etc/elasticsearch`.
  32. . If your cluster has a single node, add the `discovery.type` setting in the
  33. `$ES_PATH_CONF/elasticsearch.yml` file and set the value to `single-node`. This
  34. setting ensures that your node does not inadvertently connect to other clusters
  35. that might be running on your network.
  36. +
  37. [source,yaml]
  38. ----
  39. discovery.type: single-node
  40. ----
  41. [[security-create-builtin-users]]
  42. ==== Set passwords for built-in users
  43. To communicate with your cluster, you must configure a password for
  44. the `elastic` and `kibana_system` built-in users. Unless you enable anonymous
  45. access (not recommended), all requests that don’t include credentials are
  46. rejected.
  47. NOTE: You only need to set passwords for the `elastic` and `kibana_system` users
  48. when enabling minimal or basic security.
  49. . On *every* node in your cluster, start {es}. For example, if you installed
  50. {es} with a `.tar.gz` package, run the following command from the `ES_HOME`
  51. directory:
  52. +
  53. [source,shell]
  54. ----
  55. ./bin/elasticsearch
  56. ----
  57. . On any node in your cluster, open another terminal window and set the password
  58. for the `elastic` built-in user by running the
  59. <<reset-password,`elasticsearch-reset-password`>> utility.
  60. This command resets the password to an auto-generated value.
  61. +
  62. [source,shell]
  63. ----
  64. ./bin/elasticsearch-reset-password -u elastic
  65. ----
  66. +
  67. If you want to set the password to a specific value, run the command with the
  68. interactive (`-i`) parameter.
  69. +
  70. [source,shell]
  71. ----
  72. ./bin/elasticsearch-reset-password -i -u elastic
  73. ----
  74. . Set the password for the `kibana_system` built-in user.
  75. +
  76. [source,shell]
  77. ----
  78. ./bin/elasticsearch-reset-password -u kibana_system
  79. ----
  80. . Save the new passwords. In the next step, you'll add the the password for the
  81. `kibana_system` user to {kib}.
  82. *Next*: <<add-built-in-users,Configure {kib} to connect to {es} with a password>>
  83. [[add-built-in-users]]
  84. ==== Configure {kib} to connect to {es} with a password
  85. When the {es} security features are enabled, users must log in to {kib} with a
  86. valid username and password.
  87. You'll configure {kib} to use the built-in `kibana_system` user and the password that
  88. you created earlier. {kib} performs some background tasks that require use of the
  89. `kibana_system` user.
  90. This account is not meant for individual users and does not have permission to log in
  91. to {kib} from a browser. Instead, you'll log in to {kib} as the `elastic` superuser.
  92. . Add the `elasticsearch.username` setting to the `KBN_PATH_CONF/kibana.yml`
  93. file and set the value to the `kibana_system` user:
  94. +
  95. [source,yaml]
  96. ----
  97. elasticsearch.username: "kibana_system"
  98. ----
  99. +
  100. NOTE: The `KBN_PATH_CONF` variable is the path for the {kib}
  101. configuration files. If you installed {kib} using archive distributions
  102. (`zip` or `tar.gz`), the variable defaults to `KIB_HOME/config`. If you used
  103. package distributions (Debian or RPM), the variable defaults to `/etc/kibana`.
  104. . From the directory where you installed {kib}, run the following commands
  105. to create the {kib} keystore and add the secure settings:
  106. a. Create the {kib} keystore:
  107. +
  108. [source,shell]
  109. ----
  110. ./bin/kibana-keystore create
  111. ----
  112. b. Add the password for the `kibana_system` user to the {kib} keystore:
  113. +
  114. [source,shell]
  115. ----
  116. ./bin/kibana-keystore add elasticsearch.password
  117. ----
  118. +
  119. When prompted, enter the password for the `kibana_system` user.
  120. . Restart {kib}. For example, if you installed {kib} with a `.tar.gz` package, run the following command from the {kib} directory:
  121. +
  122. [source,shell]
  123. ----
  124. ./bin/kibana
  125. ----
  126. . Log in to {kib} as the `elastic` user. Use this superuser account to
  127. {kibana-ref}/tutorial-secure-access-to-kibana.html[manage spaces, create new users, and assign roles]. If you're running {kib} locally, go to `http://localhost:5601` to view the login page.
  128. [[minimal-security-whatsnext]]
  129. ==== What's next?
  130. Congratulations! You enabled password protection for your local cluster to
  131. prevent unauthorized access. You can log in to {kib} securely as the `elastic`
  132. user and create additional users and roles. If you're running a <<single-node-discovery,single-node cluster>>, then you can stop here.
  133. If your cluster has multiple nodes, then you must configure Transport Layer
  134. Security (TLS) between nodes. <<dev-vs-prod-mode,Production mode>> clusters
  135. will not start if you do not enable TLS.
  136. <<security-basic-setup,Set up basic security for the {stack}>> to
  137. secure all internal communication between nodes in your cluster.