security-minimal-setup.asciidoc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. [[security-minimal-setup]]
  2. === Set up minimal security for {es}
  3. ++++
  4. <titleabbrev>Set up minimal security</titleabbrev>
  5. ++++
  6. You enable the Elasticsearch security features and then create
  7. passwords for built-in users. You can add more users later, but using the
  8. built-in users simplifies the process of enabling security for your
  9. cluster.
  10. ==== Prerequisites
  11. . Install and configure {es} and {kib}. See https://www.elastic.co/guide/en/elastic-stack-get-started/current/get-started-elastic-stack.html[Getting started with the Elastic Stack].
  12. . Verify that you are using a license that includes the specific security
  13. features you want.
  14. +
  15. The basic license includes minimal security settings for the Elastic Stack, so
  16. you can just download the distribution and get to work. You can also enable a
  17. free trial license to access all features of the Elastic Stack. See https://www.elastic.co/subscriptions[subscriptions] and https://www.elastic.co/guide/en/kibana/current/managing-licenses.html[license management].
  18. ==== Enable {es} security features
  19. When you use the basic license, the {es} security features are disabled by
  20. default. Enabling the {es} security features enables basic authentication so
  21. that you can run a local cluster with username and password authentication.
  22. . Stop both {kib} and {es} if they are running.
  23. . Add the `xpack.security.enabled` setting to the `ES_PATH_CONF/elasticsearch.yml` file and set the value to `true`:
  24. +
  25. [source,yaml]
  26. ----
  27. xpack.security.enabled: true
  28. ----
  29. +
  30. NOTE: The `ES_PATH_CONF` variable is the path for the {es}
  31. configuration files. If you installed {es} using archive distributions
  32. (`zip` or `tar.gz`), the variable defaults to `ES_HOME/config`. If you used
  33. package distributions (Debian or RPM), the variable defaults to `/etc/elasticsearch`.
  34. [[security-create-builtin-users]]
  35. ==== Create passwords for built-in users
  36. To communicate with the cluster, you must configure a username for the built-in
  37. users. Unless you enable anonymous access, all requests that don’t include a
  38. user name and password are rejected.
  39. NOTE: You only need to set passwords for the `elastic` and `kibana_system` users
  40. when enabling minimal or basic security.
  41. . Start Elasticsearch. For example, if you installed Elasticsearch with a
  42. `.tar.gz` package, run the following command from the Elasticsearch directory:
  43. +
  44. [source,shell]
  45. ----
  46. ./bin/elasticsearch
  47. ----
  48. . In another terminal window, set the passwords for the built-in users by
  49. running the `elasticsearch-setup-passwords` utility. Using the `auto` parameter
  50. outputs randomly-generated passwords to the console that you can change later
  51. if necessary:
  52. +
  53. [source,shell]
  54. ----
  55. ./bin/elasticsearch-setup-passwords auto
  56. ----
  57. +
  58. If you want to use your own passwords, run the command with the
  59. `interactive` parameter instead of the `auto` parameter. Using this mode
  60. steps you through password configuration for all of the built-in users.
  61. +
  62. [source,shell]
  63. ----
  64. ./bin/elasticsearch-setup-passwords interactive
  65. ----
  66. . Save the generated passwords. You'll need them to add the built-in user to
  67. {kib}.
  68. WARNING: After you set a password for the `elastic` user, you cannot run the
  69. `elasticsearch-setup-passwords` command a second time.
  70. *Next*: <<add-built-in-users,Configure {kib} to connect to {es} with a password>>
  71. [[add-built-in-users]]
  72. ==== Configure {kib} to connect to {es} with a password
  73. When the {es} security features are enabled, users must log in to {kib} with a
  74. valid username and password.
  75. {kib} also performs some background tasks that require use of the built-in
  76. `elastic` user.
  77. You'll configure {kib} to use the built-in `elastic` user and the
  78. password that you created earlier.
  79. . Add the `elasticsearch.username` setting to the `KIB_PATH_CONF/kibana.yml`
  80. file and set the value to the `elastic` user:
  81. +
  82. [source,yaml]
  83. ----
  84. elasticsearch.username: "elastic"
  85. ----
  86. +
  87. NOTE: The `KIB_PATH_CONF` variable is the path for the {kib}
  88. configuration files. If you installed {kib} using archive distributions
  89. (`zip` or `tar.gz`), the variable defaults to `KIB_HOME/config`. If you used
  90. package distributions (Debian or RPM), the variable defaults to `/etc/kibana`.
  91. . From the directory where you installed {kib}, run the following commands
  92. to create the {kib} keystore and add the secure settings:
  93. a. Create the {kib} keystore:
  94. +
  95. [source,shell]
  96. ----
  97. ./bin/kibana-keystore create
  98. ----
  99. b. Add the password for the `elastic` user to the {kib} keystore:
  100. +
  101. [source,shell]
  102. ----
  103. ./bin/kibana-keystore add elasticsearch.password
  104. ----
  105. +
  106. When prompted, enter the password for the `elastic` user.
  107. . Restart {kib}. For example, if you installed {kib} with a `.tar.gz` package, run the following command from the {kib} directory:
  108. +
  109. [source,shell]
  110. ----
  111. ./bin/kibana
  112. ----
  113. . Log in to {kib} as the `elastic` user.
  114. [[minimal-security-whatsnext]]
  115. ==== What's next?
  116. Congratulations! You enabled password protection for your local cluster to
  117. prevent unauthorized access. You can log in to {kib} securely as the `elastic`
  118. user.
  119. To add another layer of security, <<security-basic-setup,Set up basic security for the Elastic Stack>>. You'll configure Transport Layer Security (TLS) to
  120. secure all internal communication between nodes in your cluster.