backup-and-restore-security-config.asciidoc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[security-backup]]
  4. === Back up a cluster's security configuration
  5. ++++
  6. <titleabbrev>Back up the security configuration</titleabbrev>
  7. ++++
  8. Security configuration information resides in two places:
  9. <<backup-security-file-based-configuration,files>> and
  10. <<backup-security-index-configuration,indices>>.
  11. [discrete]
  12. [[backup-security-file-based-configuration]]
  13. ==== Back up file-based security configuration
  14. {es} {security-features} are configured using the <<security-settings,
  15. `xpack.security` namespace>> inside the `elasticsearch.yml` and
  16. `elasticsearch.keystore` files. In addition there are several other
  17. <<security-files, extra configuration files>> inside the same `ES_PATH_CONF`
  18. directory. These files define roles and role mappings and configure the
  19. <<file-realm,file realm>>. Some of the
  20. settings specify file paths to security-sensitive data, such as TLS keys and
  21. certificates for the HTTP client and inter-node communication and private key files for
  22. <<ref-saml-settings, SAML>>, <<ref-oidc-settings, OIDC>> and the
  23. <<ref-kerberos-settings, Kerberos>> realms. All these are also stored inside
  24. `ES_PATH_CONF`; the path settings are relative.
  25. IMPORTANT: The `elasticsearch.keystore`, TLS keys and SAML, OIDC, and Kerberos
  26. realms private key files require confidentiality. This is crucial when files
  27. are copied to the backup location, as this increases the surface for malicious
  28. snooping.
  29. To back up all this configuration you can use a <<backup-cluster-configuration,
  30. conventional file-based backup>>, as described in the previous section.
  31. [NOTE]
  32. ====
  33. * File backups must run on every cluster node.
  34. * File backups will store non-security configuration as well. Backing-up
  35. only {security-features} configuration is not supported. A backup is a
  36. point in time record of state of the complete configuration.
  37. ====
  38. [discrete]
  39. [[backup-security-index-configuration]]
  40. ==== Back up index-based security configuration
  41. {es} {security-features} store system configuration data inside a
  42. dedicated index. This index is named `.security-6` in the {es} 6.x versions and
  43. `.security-7` in the 7.x releases. The `.security` alias always points to the
  44. appropriate index. This index contains the data which is not available in
  45. configuration files and *cannot* be reliably backed up using standard
  46. filesystem tools. This data describes:
  47. * the definition of users in the native realm (including hashed passwords)
  48. * role definitions (defined via the <<security-api-put-role,create roles API>>)
  49. * role mappings (defined via the
  50. <<security-api-put-role-mapping,create role mappings API>>)
  51. * application privileges
  52. * API keys
  53. The `.security` index thus contains resources and definitions in addition to
  54. configuration information. All of that information is required in a complete
  55. {security-features} backup.
  56. Use the <<modules-snapshots, standard {es} snapshot functionality>> to backup
  57. `.security`, as you would for any <<backup-cluster-data, other data index>>.
  58. For convenience, here are the complete steps:
  59. . Create a repository that you can use to backup the `.security` index.
  60. It is preferable to have a <<backup-security-repos, dedicated repository>> for
  61. this special index. If you wish, you can also snapshot the system indices for other {stack} components to this repository.
  62. +
  63. --
  64. [source,console]
  65. -----------------------------------
  66. PUT /_snapshot/my_backup
  67. {
  68. "type": "fs",
  69. "settings": {
  70. "location": "my_backup_location"
  71. }
  72. }
  73. -----------------------------------
  74. The user calling this API must have the elevated `manage` cluster privilege to
  75. prevent non-administrators exfiltrating data.
  76. --
  77. . Create a user and assign it only the built-in `snapshot_user` role.
  78. +
  79. --
  80. The following example creates a new user `snapshot_user` in the
  81. <<native-realm,native realm>>, but it is not important which
  82. realm the user is a member of:
  83. [source,console]
  84. --------------------------------------------------
  85. POST /_security/user/snapshot_user
  86. {
  87. "password" : "secret",
  88. "roles" : [ "snapshot_user" ]
  89. }
  90. --------------------------------------------------
  91. // TEST[skip:security is not enabled in this fixture]
  92. --
  93. . Create incremental snapshots authorized as `snapshot_user`.
  94. +
  95. --
  96. The following example shows how to use the create snapshot API to backup
  97. the `.security` index to the `my_backup` repository:
  98. [source,console]
  99. --------------------------------------------------
  100. PUT /_snapshot/my_backup/snapshot_1
  101. {
  102. "indices": ".security",
  103. "include_global_state": true <1>
  104. }
  105. --------------------------------------------------
  106. // TEST[continued]
  107. <1> This parameter value captures all the persistent settings stored in the
  108. global cluster metadata as well as other configurations such as aliases and
  109. stored scripts. Note that this includes non-security configuration and that it complements but does not replace the
  110. <<backup-cluster-configuration, filesystem configuration files backup>>.
  111. --
  112. IMPORTANT: The index format is only compatible within a single major version,
  113. and cannot be restored onto a version earlier than the version from which it
  114. originated. For example, you can restore a security snapshot from 6.6.0 into a
  115. 6.7.0 cluster, but you cannot restore it to a cluster running {es} 6.5.0 or 7.0.0.
  116. [discrete]
  117. [[backup-security-repos]]
  118. ===== Controlling access to the backup repository
  119. The snapshot of the security index will typically contain sensitive data such
  120. as user names and password hashes. Because passwords are stored using
  121. <<hashing-settings, cryptographic hashes>>, the disclosure of a snapshot would
  122. not automatically enable a third party to authenticate as one of your users or
  123. use API keys. However, it would disclose confidential information.
  124. It is also important that you protect the integrity of these backups in case
  125. you ever need to restore them. If a third party is able to modify the stored
  126. backups, they may be able to install a back door that would grant access if the
  127. snapshot is loaded into an {es} cluster.
  128. We recommend that you:
  129. * Snapshot the `.security` index in a dedicated repository, where read and write
  130. access is strictly restricted and audited.
  131. * If there are indications that the snapshot has been read, change the passwords
  132. of the users in the native realm and revoke API keys.
  133. * If there are indications that the snapshot has been tampered with, do not
  134. restore it. There is currently no option for the restore process to detect
  135. malicious tampering.