remote-clusters-api-key.asciidoc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. [[remote-clusters-api-key]]
  2. === Add remote clusters using API key authentication
  3. coming::[8.10]
  4. beta::[]
  5. API key authentication enables a local cluster to authenticate itself with a
  6. remote cluster via a <<security-api-create-cross-cluster-api-key,cross-cluster
  7. API key>>. The API key needs to be created by an administrator of the remote
  8. cluster. The local cluster is configured to provide this API key on each request
  9. to the remote cluster. The remote cluster verifies the API key and grants
  10. access, based on the API key's privileges.
  11. All cross-cluster requests from the local cluster are bound by the API key's
  12. privileges, regardless of local users associated with the requests. For example,
  13. if the API key only allows read access to `my-index` on the remote cluster, even
  14. a superuser from the local cluster is limited by this constraint. This mechanism
  15. enables the remote cluster's administrator to have full control over who can
  16. access what data with cross-cluster search and/or cross-cluster replication. The
  17. remote cluster's administrator can be confident that no access is possible
  18. beyond what is explicitly assigned to the API key.
  19. On the local cluster side, not every local user needs to access every piece of
  20. data allowed by the API key. An administrator of the local cluster can further
  21. configure additional permission constraints on local users so each user only
  22. gets access to the necessary remote data. Note it is only possible to further
  23. reduce the permissions allowed by the API key for individual local users. It is
  24. impossible to increase the permissions to go beyond what is allowed by the API
  25. key.
  26. In this model, cross-cluster operations use <<remote_cluster.port,a dedicated
  27. server port>> (remote cluster interface) for communication between clusters. A
  28. remote cluster must enable this port for local clusters to connect. Configure
  29. Transport Layer Security (TLS) for this port to maximize security (as explained
  30. in <<remote-clusters-security-api-key>>).
  31. The local cluster must trust the remote cluster on the remote cluster interface.
  32. This means that the local cluster trusts the remote cluster's certificate
  33. authority (CA) that signs the server certificate used by the remote cluster
  34. interface. When establishing a connection, all nodes from the local cluster that
  35. participate in cross-cluster communication verify certificates from nodes on the
  36. other side, based on the TLS trust configuration.
  37. To add a remote cluster using API key authentication:
  38. . <<remote-clusters-prerequisites-api-key,Review the prerequisites>>
  39. . <<remote-clusters-security-api-key>>
  40. . <<remote-clusters-connect-api-key>>
  41. . <<remote-clusters-privileges-api-key>>
  42. If you run into any issues, refer to <<remote-clusters-troubleshooting>>.
  43. [[remote-clusters-prerequisites-api-key]]
  44. ==== Prerequisites
  45. * The {es} security features need to be enabled on both clusters, on every node.
  46. Security is enabled by default. If it's disabled, set `xpack.security.enabled`
  47. to `true` in `elasticsearch.yml`. Refer to <<general-security-settings>>.
  48. * The nodes of the local and remote clusters must be on version 8.10 or later.
  49. * The local and remote clusters must have an appropriate license. For more
  50. information, refer to https://www.elastic.co/subscriptions.
  51. [[remote-clusters-security-api-key]]
  52. ==== Establish trust with a remote cluster
  53. ===== On the remote cluster
  54. // tag::remote-cluster-steps[]
  55. . Enable the remote cluster server on every node of the remote cluster. In
  56. `elasticsearch.yml`:
  57. .. Set <<remote-cluster-network-settings,`remote_cluster_server.enabled`>> to
  58. `true`.
  59. .. Configure the bind and publish address for remote cluster server traffic, for
  60. example using <<remote-cluster-network-settings,`remote_cluster.host`>>. Without
  61. configuring the address, remote cluster traffic may be bound to the local
  62. interface, and remote clusters running on other machines can't connect.
  63. .. Optionally, configure the remote server port using
  64. <<remote_cluster.port,`remote_cluster.port`>> (defaults to `9443`).
  65. . Next, generate a certificate authority (CA) and a server certificate/key pair.
  66. On one of the nodes of the remote cluster, from the directory where {es} has
  67. been installed:
  68. .. Create a CA, if you don't have a CA already:
  69. +
  70. [source,sh]
  71. ----
  72. ./bin/elasticsearch-certutil ca --pem --out=cross-cluster-ca.zip --pass CA_PASSWORD
  73. ----
  74. +
  75. Replace `CA_PASSWORD` with the password you want to use for the CA. You can
  76. remove the `--pass` option and its argument if you are not deploying to a
  77. production environment.
  78. .. Unzip the generated `cross-cluster-ca.zip` file. This compressed file
  79. contains the following content:
  80. +
  81. [source,txt]
  82. ----
  83. /ca
  84. |_ ca.crt
  85. |_ ca.key
  86. ----
  87. .. Generate a certificate and private key pair for the nodes in the remote
  88. cluster:
  89. +
  90. [source,sh]
  91. ----
  92. ./bin/elasticsearch-certutil cert --out=cross-cluster.p12 --pass=CERT_PASSWORD --ca-cert=ca/ca.crt --ca-key=ca/ca.key --ca-pass=CA_PASSWORD --dns=example.com --ip=127.0.0.1
  93. ----
  94. +
  95. * Replace `CA_PASSWORD` with the CA password from the previous step.
  96. * Replace `CERT_PASSWORD` with the password you want to use for the generated
  97. private key.
  98. * Use the `--dns` option to specify the relevant DNS name for the certificate.
  99. You can specify it multiple times for multiple DNS.
  100. * Use the `--ip` option to specify the relevant IP address for the certificate.
  101. You can specify it multiple times for multiple IP addresses.
  102. .. If the remote cluster has multiple nodes, you can either:
  103. +
  104. * create a single wildcard certificate for all nodes;
  105. * or, create separate certificates for each node either manually or in batch
  106. with the <<certutil-silent,silent mode>>.
  107. . On every node of the remote cluster:
  108. .. Copy the `cross-cluster.p12` file from the earlier step to the `config`
  109. directory. If you didn't create a wildcard certificate, make sure you copy the
  110. correct node-specific p12 file.
  111. .. Add following configuration to `elasticsearch.yml`:
  112. +
  113. [source,yaml]
  114. ----
  115. xpack.security.remote_cluster_server.ssl.enabled: true
  116. xpack.security.remote_cluster_server.ssl.keystore.path: cross-cluster.p12
  117. ----
  118. .. Add the SSL keystore password to the {es} keystore:
  119. +
  120. [source,sh]
  121. ----
  122. ./bin/elasticsearch-keystore add xpack.security.remote_cluster_server.ssl.keystore.secure_password
  123. ----
  124. +
  125. When prompted, enter the `CERT_PASSWORD` from the earlier step.
  126. . Restart the remote cluster.
  127. . On the remote cluster, generate a cross-cluster API key that provides access
  128. to the indices you want to use for {ccs} or {ccr}. You can use the
  129. <<security-api-create-cross-cluster-api-key>> API or
  130. {kibana-ref}/api-keys.html[Kibana].
  131. . Copy the encoded key (`encoded` in the response) to a safe location. You will
  132. need it to connect to the remote cluster later.
  133. // end::remote-cluster-steps[]
  134. ===== On the local cluster
  135. // tag::local-cluster-steps[]
  136. . On every node of the local cluster:
  137. .. Copy the `ca.crt` file generated on the remote cluster earlier into the
  138. `config` directory, renaming the file `remote-cluster-ca.crt`.
  139. .. Add following configuration to `elasticsearch.yml`:
  140. +
  141. [source,yaml]
  142. ----
  143. xpack.security.remote_cluster_client.ssl.enabled: true
  144. xpack.security.remote_cluster_client.ssl.certificate_authorities: [ "remote-cluster-ca.crt" ]
  145. ----
  146. // end::local-cluster-steps[]
  147. .. Add the cross-cluster API key, created on the remote cluster earlier, to the
  148. keystore:
  149. +
  150. [source,sh]
  151. ----
  152. ./bin/elasticsearch-keystore add cluster.remote.ALIAS.credentials
  153. ----
  154. +
  155. Replace `ALIAS` with the alias you will use to connect to the remote cluster
  156. later. When prompted, enter the encoded cross-cluster API key created on the
  157. remote cluster earlier.
  158. . Restart the local cluster to load the keystore change.
  159. [[remote-clusters-connect-api-key]]
  160. ==== Connect to a remote cluster
  161. :trust-mechanism: api-key
  162. include::remote-clusters-connect.asciidoc[]
  163. :!trust-mechanism:
  164. include::../../../../x-pack/docs/en/security/authentication/remote-clusters-privileges-api-key.asciidoc[leveloffset=+1]