remote-clusters-api-key.asciidoc 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. [[remote-clusters-prerequisites-api-key]]
  43. ==== Prerequisites
  44. * The {es} security features need to be enabled on both clusters, on every node.
  45. Security is enabled by default. If it's disabled, set `xpack.security.enabled`
  46. to `true` in `elasticsearch.yml`. Refer to <<general-security-settings>>.
  47. * The nodes of the local and remote clusters must be on version 8.10 or later.
  48. * The local and remote clusters must have an appropriate license. For more
  49. information, refer to https://www.elastic.co/subscriptions.
  50. [[remote-clusters-security-api-key]]
  51. ==== Establish trust with a remote cluster
  52. ===== On the remote cluster
  53. . Enable the remote cluster server port on every node of the remote cluster by
  54. setting `remote_cluster_server.enabled` to `true` in `elasticsearch.yml`. The
  55. port number defaults to `9443` and can be configured with the
  56. `remote_cluster.port` setting. Refer to <<remote-cluster-network-settings>>.
  57. . Next, generate a CA and a server certificate/key pair. On one of the nodes
  58. of the remote cluster, from the directory where {es} has been installed:
  59. .. Create a CA, if you don't have a CA already:
  60. +
  61. [source,sh]
  62. ----
  63. ./bin/elasticsearch-certutil ca --pem --out=cross-cluster-ca.zip --pass CA_PASSWORD
  64. ----
  65. +
  66. Replace `CA_PASSWORD` with the password you want to use for the CA. You can
  67. remove the `--pass` option and its argument if you are not deploying to a
  68. production environment.
  69. .. Unzip the generated `cross-cluster-ca.zip` file. This compressed file
  70. contains the following content:
  71. +
  72. [source,txt]
  73. ----
  74. /ca
  75. |_ ca.crt
  76. |_ ca.key
  77. ----
  78. .. Generate a certificate and private key pair for the nodes in the remote
  79. cluster:
  80. +
  81. [source,sh]
  82. ----
  83. ./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
  84. ----
  85. +
  86. * Replace `CA_PASSWORD` with the CA password from the previous step.
  87. * Replace `CERT_PASSWORD` with the password you want to use for the generated
  88. private key.
  89. * Use the `--dns` option to specify the relevant DNS name for the certificate.
  90. You can specify it multiple times for multiple DNS.
  91. * Use the `--ip` option to specify the relevant IP address for the certificate.
  92. You can specify it multiple times for multiple IP addresses.
  93. .. If the remote cluster has multiple nodes, you can either:
  94. +
  95. * create a single wildcard certificate for all nodes;
  96. * or, create separate certificates for each node either manually or in batch
  97. with the <<certutil-silent,silent mode>>.
  98. . On every node of the remote cluster:
  99. .. Copy the `cross-cluster.p12` file from the earlier step to the `config`
  100. directory. If you didn't create a wildcard certificate, make sure you copy the
  101. correct node-specific p12 file.
  102. .. Add following configuration to `elasticsearch.yml`:
  103. +
  104. [source,yaml]
  105. ----
  106. xpack.security.remote_cluster_server.ssl.enabled: true
  107. xpack.security.remote_cluster_server.ssl.keystore.path: cross-cluster.p12
  108. ----
  109. .. Add the SSL keystore password to the {es} keystore:
  110. +
  111. [source,sh]
  112. ----
  113. ./bin/elasticsearch-keystore add xpack.security.remote_cluster_server.ssl.keystore.secure_password
  114. ----
  115. +
  116. When prompted, enter the `CERT_PASSWORD` from the earlier step.
  117. . Restart the remote cluster.
  118. . On the remote cluster, generate a cross-cluster API key using the
  119. <<security-api-create-cross-cluster-api-key>> API or
  120. {kibana-ref}/api-keys.html[Kibana]. Grant the key the required access for {ccs}
  121. or {ccr}.
  122. . Copy the encoded key (`encoded` in the response) to a safe location. You will
  123. need it to connect to the remote cluster later.
  124. ===== On the local cluster
  125. . On every node of the local cluster:
  126. .. Copy the `ca.crt` file generated on the remote cluster earlier into the
  127. `config` directory, renaming the file `remote-cluster-ca.crt`.
  128. .. Add following configuration to `elasticsearch.yml`:
  129. +
  130. [source,yaml]
  131. ----
  132. xpack.security.remote_cluster_client.ssl.enabled: true
  133. xpack.security.remote_cluster_client.ssl.certificate_authorities: [ "remote-cluster-ca.crt" ]
  134. ----
  135. .. Add the cross-cluster API key, created on the remote cluster earlier, to the
  136. keystore:
  137. +
  138. [source,sh]
  139. ----
  140. ./bin/elasticsearch-keystore add cluster.remote.ALIAS.credentials
  141. ----
  142. +
  143. Replace `ALIAS` with the alias you will use to connect to the remote cluster
  144. later. When prompted, enter the encoded cross-cluster API key created on the
  145. remote cluster earlier.
  146. . Restart the local cluster to load the keystore change.
  147. [[remote-clusters-connect-api-key]]
  148. ==== Connect to a remote cluster
  149. :trust-mechanism: api-key
  150. include::remote-clusters-connect.asciidoc[]
  151. :!trust-mechanism:
  152. include::../../../../x-pack/docs/en/security/authentication/remote-clusters-privileges-api-key.asciidoc[leveloffset=+1]