keystore.asciidoc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. [[elasticsearch-keystore]]
  2. == elasticsearch-keystore
  3. The `elasticsearch-keystore` command manages <<secure-settings,secure settings>>
  4. in the {es} keystore.
  5. [discrete]
  6. [[elasticsearch-keystore-synopsis]]
  7. === Synopsis
  8. [source,shell]
  9. --------------------------------------------------
  10. bin/elasticsearch-keystore
  11. ( [add <settings>] [-f] [--stdin]
  12. | [add-file (<setting> <path>)+]
  13. | [create] [-p]
  14. | [has-passwd]
  15. | [list]
  16. | [passwd]
  17. | [remove <setting>]
  18. | [show [-o <output-file>] <setting>]
  19. | [upgrade]
  20. ) [-h, --help] ([-s, --silent] | [-v, --verbose])
  21. --------------------------------------------------
  22. [discrete]
  23. [[elasticsearch-keystore-description]]
  24. === Description
  25. IMPORTANT: This command should be run as the user that will run {es}.
  26. Currently, all secure settings are node-specific settings that must have the
  27. same value on every node. Therefore you must run this command on every node.
  28. When the keystore is password-protected, you must supply the password each time
  29. {es} starts.
  30. Modifications to the keystore are not automatically applied to the running {es}
  31. node.
  32. Any changes to the keystore will take effect when you restart {es}.
  33. Some secure settings can be explicitly <<reloadable-secure-settings, reloaded>>
  34. without restart.
  35. Only some settings are designed to be read from the keystore. However, there
  36. is no validation to block unsupported settings from the keystore and they can
  37. cause {es} to fail to start. To see whether a setting is supported in the
  38. keystore, see the setting reference.
  39. [discrete]
  40. [[elasticsearch-keystore-parameters]]
  41. === Parameters
  42. `add <settings>`:: Adds settings to the keystore. Multiple setting names can be
  43. specified as arguments to the `add` command. By default, you are prompted for
  44. the values of the settings. If the keystore is password protected, you are also
  45. prompted to enter the password. If a setting already exists in the keystore, you
  46. must confirm that you want to overwrite the current value. If the keystore does
  47. not exist, you must confirm that you want to create a keystore. To avoid these
  48. two confirmation prompts, use the `-f` parameter.
  49. `add-file (<setting> <path>)+`:: Adds files to the keystore.
  50. `create`:: Creates the keystore.
  51. `-f, --force`:: When used with the `add` parameter, the command no longer prompts you
  52. before overwriting existing entries in the keystore. Also, if you haven't
  53. created a keystore yet, it creates a keystore that is obfuscated but not
  54. password protected.
  55. `-h, --help`:: Returns all of the command parameters.
  56. `has-passwd`:: Returns a success message if the keystore exists and is
  57. password-protected. Otherwise, the command fails with exit code 1 and returns an
  58. error message.
  59. `list`:: Lists the settings in the keystore. If the keystore is password
  60. protected, you are prompted to enter the password.
  61. `-p`:: When used with the `create` parameter, the command prompts you to enter a
  62. keystore password. If you don't specify the `-p` flag or if you enter an empty
  63. password, the keystore is obfuscated but not password protected.
  64. `passwd`:: Changes or sets the keystore password. If the keystore is password
  65. protected, you are prompted to enter the current password and the new one. You
  66. can optionally use an empty string to remove the password. If the keystore is
  67. not password protected, you can use this command to set a password.
  68. `remove <settings>`:: Removes settings from the keystore. Multiple setting
  69. names can be specified as arguments to the `remove` command.
  70. `show <setting>`:: Displays the value of a single setting in the keystore.
  71. Pass the `-o` (or `--output`) parameter to write the setting to a file.
  72. If writing to the standard output (the terminal) the setting's value is always
  73. interpreted as a UTF-8 string. If the setting contains binary data (for example
  74. for data that was added via the `add-file` command), always use the `-o` option
  75. to write to a file.
  76. `-s, --silent`:: Shows minimal output.
  77. `-x, --stdin`:: When used with the `add` parameter, you can pass the settings values
  78. through standard input (stdin). Separate multiple values with carriage returns
  79. or newlines. See <<add-string-to-keystore>>.
  80. `upgrade`:: Upgrades the internal format of the keystore.
  81. `-v, --verbose`:: Shows verbose output.
  82. [discrete]
  83. [[elasticsearch-keystore-examples]]
  84. === Examples
  85. [discrete]
  86. [[creating-keystore]]
  87. ==== Create the keystore
  88. To create the `elasticsearch.keystore`, use the `create` command:
  89. [source,sh]
  90. ----------------------------------------------------------------
  91. bin/elasticsearch-keystore create -p
  92. ----------------------------------------------------------------
  93. You are prompted to enter the keystore password. A password-protected
  94. `elasticsearch.keystore` file is created alongside the `elasticsearch.yml` file.
  95. [discrete]
  96. [[changing-keystore-password]]
  97. ==== Change the password of the keystore
  98. To change the password of the `elasticsearch.keystore`, use the `passwd` command:
  99. [source,sh]
  100. ----------------------------------------------------------------
  101. bin/elasticsearch-keystore passwd
  102. ----------------------------------------------------------------
  103. If the {es} keystore is password protected, you are prompted to enter the
  104. current password and then enter the new one. If it is not password protected,
  105. you are prompted to set a password.
  106. [discrete]
  107. [[list-settings]]
  108. ==== List settings in the keystore
  109. To list the settings in the keystore, use the `list` command.
  110. [source,sh]
  111. ----------------------------------------------------------------
  112. bin/elasticsearch-keystore list
  113. ----------------------------------------------------------------
  114. If the {es} keystore is password protected, you are prompted to enter the
  115. password.
  116. [discrete]
  117. [[add-string-to-keystore]]
  118. ==== Add settings to the keystore
  119. Sensitive string settings, like authentication credentials for Cloud plugins,
  120. can be added with the `add` command:
  121. [source,sh]
  122. ----------------------------------------------------------------
  123. bin/elasticsearch-keystore add the.setting.name.to.set
  124. ----------------------------------------------------------------
  125. You are prompted to enter the value of the setting. If the {es} keystore is
  126. password protected, you are also prompted to enter the password.
  127. You can also add multiple settings with the `add` command:
  128. [source,sh]
  129. ----------------------------------------------------------------
  130. bin/elasticsearch-keystore add \
  131. the.setting.name.to.set \
  132. the.other.setting.name.to.set
  133. ----------------------------------------------------------------
  134. You are prompted to enter the values of the settings. If the {es} keystore is
  135. password protected, you are also prompted to enter the password.
  136. To pass the settings values through standard input (stdin), use the `--stdin`
  137. flag:
  138. [source,sh]
  139. ----------------------------------------------------------------
  140. cat /file/containing/setting/value | bin/elasticsearch-keystore add --stdin the.setting.name.to.set
  141. ----------------------------------------------------------------
  142. Values for multiple settings must be separated by carriage returns or newlines.
  143. [discrete]
  144. [[add-file-to-keystore]]
  145. ==== Add files to the keystore
  146. You can add sensitive files, like authentication key files for Cloud plugins,
  147. using the `add-file` command. Settings and file paths are specified in pairs
  148. consisting of `setting path`.
  149. [source,sh]
  150. ----------------------------------------------------------------
  151. bin/elasticsearch-keystore add-file the.setting.name.to.set /path/example-file.json
  152. ----------------------------------------------------------------
  153. You can add multiple files with the `add-file` command:
  154. [source,sh]
  155. ----------------------------------------------------------------
  156. bin/elasticsearch-keystore add-file \
  157. the.setting.name.to.set /path/example-file.json \
  158. the.other.setting.name.to.set /path/other-example-file.json
  159. ----------------------------------------------------------------
  160. If the {es} keystore is password protected, you are prompted to enter the
  161. password.
  162. [discrete]
  163. [[show-keystore-value]]
  164. ==== Show settings in the keystore
  165. To display the value of a setting in the keystore use the `show` command:
  166. [source,sh]
  167. ----------------------------------------------------------------
  168. bin/elasticsearch-keystore show the.name.of.the.setting.to.show
  169. ----------------------------------------------------------------
  170. If the setting contains binary data you should write it to a file with the
  171. `-o` (or `--output`) option:
  172. [source,sh]
  173. ----------------------------------------------------------------
  174. bin/elasticsearch-keystore show -o my_file binary.setting.name
  175. ----------------------------------------------------------------
  176. If the {es} keystore is password protected, you are prompted to enter the
  177. password.
  178. [discrete]
  179. [[remove-settings]]
  180. ==== Remove settings from the keystore
  181. To remove a setting from the keystore, use the `remove` command:
  182. [source,sh]
  183. ----------------------------------------------------------------
  184. bin/elasticsearch-keystore remove the.setting.name.to.remove
  185. ----------------------------------------------------------------
  186. You can also remove multiple settings with the `remove` command:
  187. [source,sh]
  188. ----------------------------------------------------------------
  189. bin/elasticsearch-keystore remove \
  190. the.setting.name.to.remove \
  191. the.other.setting.name.to.remove
  192. ----------------------------------------------------------------
  193. If the {es} keystore is password protected, you are prompted to enter the
  194. password.
  195. [discrete]
  196. [[keystore-upgrade]]
  197. ==== Upgrade the keystore
  198. Occasionally, the internal format of the keystore changes. When {es} is
  199. installed from a package manager, an upgrade of the on-disk keystore to the new
  200. format is done during package upgrade. In other cases, {es} performs the upgrade
  201. during node startup. This requires that {es} has write permissions to the
  202. directory that contains the keystore. Alternatively, you can manually perform
  203. such an upgrade by using the `upgrade` command:
  204. [source,sh]
  205. ----------------------------------------------------------------
  206. bin/elasticsearch-keystore upgrade
  207. ----------------------------------------------------------------