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

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