Skip to content

Commit 30fe943

Browse files
authored
Merge branch 'main' into leemthompo/agent-builder-api
2 parents da5ef09 + 2cd77c6 commit 30fe943

File tree

5 files changed

+254
-21
lines changed

5 files changed

+254
-21
lines changed

deploy-manage/users-roles/cluster-or-deployment-auth/file-based.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ mapped_pages:
55
- https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-users-and-roles.html
66
applies_to:
77
deployment:
8-
self: all
9-
eck: all
8+
self: ga
9+
eck: ga
1010
products:
1111
- id: elasticsearch
1212
- id: cloud-kubernetes
@@ -16,11 +16,7 @@ products:
1616

1717
You can manage and authenticate users with the built-in `file` realm. With the `file` realm, users are defined in local files on each node in the cluster.
1818

19-
The `file` realm is useful as a fallback or recovery realm. For example in cases where the cluster is unresponsive or the security index is unavailable, or when you forget the password for your administrative users. In this type of scenario, the `file` realm is a convenient workaround: you can define a new `admin` user in the `file` realm and use it to log in and reset the credentials of all other users.
20-
21-
You can configure only one file realm on {{es}} nodes.
22-
23-
Refer to [enabling a file realm user for recovery](https://www.youtube.com/watch?v=sueO7sz1buw) for a video walkthrough.
19+
The `file` realm is useful as a fallback or recovery realm. For example, you might use this realm in cases where the cluster is unresponsive or the security index is unavailable, or when you forget the password for your administrative users. In this type of scenario, the `file` realm is a convenient workaround: you can define a new `admin` user in the `file` realm and use it to log in and reset the credentials of all other users. For a walkthrough of this process, refer to [](/troubleshoot/elasticsearch/file-based-recovery.md). Refer to [enabling a file realm user for recovery](https://www.youtube.com/watch?v=sueO7sz1buw) for a video walkthrough.
2420

2521
::::{important}
2622
* In self-managed deployments, as the administrator of the cluster, it is your responsibility to ensure the same users are defined on every node in the cluster. The {{stack}} {{security-features}} do not deliver any mechanism to guarantee this.
@@ -29,33 +25,27 @@ Refer to [enabling a file realm user for recovery](https://www.youtube.com/watch
2925

3026
## Configure a file realm [file-realm-configuration]
3127

32-
You don’t need to explicitly configure a `file` realm. The `file` and `native` realms are added to the realm chain by default. Unless configured otherwise, the `file` realm is added first, followed by the `native` realm. You can define only one `file` realm per node.
28+
You don’t need to explicitly configure a `file` realm. The `file` and `native` realms are added to the realm chain by default. Unless configured otherwise, the `file` realm is added first, followed by the `native` realm. You can define only one `file` realm on each node.
3329

3430
1. (Optional) Add a realm configuration to [`elasticsearch.yml`](/deploy-manage/stack-settings.md) under the `xpack.security.authc.realms.file` namespace. At a minimum, you must set the realm’s `order` attribute.
3531

3632
For example, the following snippet shows a `file` realm configuration that sets the `order` to zero so the realm is checked first:
3733

3834
```yaml
39-
xpack:
40-
security:
41-
authc:
42-
realms:
43-
file:
44-
file1:
45-
order: 0
35+
xpack.security.authc.realms.file.file1.order: 0
4636
```
4737
48-
2. If you're using a self-managed {{es}} cluster, optionally change how often the `users` and `users_roles` files are checked.
38+
2. (Optional) For self-managed deployments, you can change how often the `users` and `users_roles` files are checked.
4939

5040
By default, {{es}} checks these files for changes every 5 seconds. You can change this default behavior by changing the `resource.reload.interval.high` setting in the [`elasticsearch.yml`](/deploy-manage/stack-settings.md) file.
5141

5242
:::{{warning}}
5343
Because `resource.reload.interval.high` is a common setting in {{es}}, changing its value may effect other schedules in the system.
5444
:::
5545

56-
3. Restart {{es}}.
46+
3. In self-managed deployments, if either of these settings is modified, perform a [rolling restart](/deploy-manage/maintenance/start-stop-services/full-cluster-restart-rolling-restart-procedures.md#restart-cluster-rolling) of the {{es}} nodes for your changes to take effect.
5747

58-
In {{eck}}, this change is propagated automatically.
48+
In {{eck}}, changes are automatically propagated.
5949

6050

6151
## Add users
@@ -120,13 +110,13 @@ In a self-managed cluster, you can edit the contents of `ES_PATH_CONF/users` and
120110
:::{tab-item} {{eck}}
121111
You can pass `users` and `user_roles` files to {{eck}} using a file realm secret:
122112
123-
```yaml
113+
```yaml subs=true
124114
apiVersion: elasticsearch.k8s.elastic.co/v1
125115
kind: Elasticsearch
126116
metadata:
127117
name: elasticsearch-sample
128118
spec:
129-
version: 8.16.1
119+
version: {{version.stack}}
130120
auth:
131121
fileRealm:
132122
- secretName: my-filerealm-secret-1

solutions/search/elastic-agent-builder.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ These pages are hidden from the docs TOC and have `noindexed` meta headers.
1414

1515
# {{agent-builder}}
1616

17-
{{agent-builder}} is an AI-powered conversation framework for working with {{es}} data using natural language. It features both a chat UI for synchronous interaction and extensive programmatic access through APIs, MCP and A2A servers.
17+
{{agent-builder}} is a set of AI-powered capabilities for developing and interacting with agents that work with your {{es}} data. Agent Builder simplifies building data-driven agents with intuitive UI and programmatic interfaces, so you don't have to compose the different pieces separately.
18+
19+
You can use the built-in agent for natural language conversations with any {{es}} data or instance, or work programmatically with tools, agents, and conversations using Elastic APIs, MCP, and A2A.
1820

1921
## Key capabilities
2022

troubleshoot/elasticsearch.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ If you're using {{ech}}, you can use AutoOps to monitor your cluster. AutoOps si
3636

3737
* [](/troubleshoot/elasticsearch/start-ilm.md)
3838
* [](/troubleshoot/elasticsearch/index-lifecycle-management-errors.md)
39+
* [](/troubleshoot/elasticsearch/file-based-recovery.md)
3940

4041
## Capacity [troubleshooting-capacity]
4142

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
---
2+
applies_to:
3+
deployment:
4+
eck: ga
5+
self: ga
6+
products:
7+
- id: elasticsearch
8+
- id: cloud-kubernetes
9+
---
10+
11+
# File-based access recovery
12+
13+
The [built-in `file` realm](/deploy-manage/users-roles/cluster-or-deployment-auth/file-based.md) is commonly used as a fallback or recovery realm.
14+
15+
The main {{stack}} {{security-features}} rely on the `security` [feature state](/deploy-manage/tools/snapshot-and-restore.md) which is mostly composed of the `.security*` [system indices](elasticsearch://reference/elasticsearch/rest-apis/api-conventions.md#system-indices). The `file` realm acts as a failsafe to expand this feature's functionality from the cluster level down to each individual node.
16+
17+
The `file` realm is especially helpful for recovery scenarios where normal security mechanisms aren't accessible:
18+
19+
* Node services are running but cluster is unresponsive
20+
* {{stack}} {{security-features}} are unavailable to the current node
21+
* {{stack}} {{security-features}} are [lost and need to be restored](/troubleshoot/elasticsearch/red-yellow-cluster-status.md#fix-cluster-status-restore)
22+
* Administrative users' passwords are lost and [need to be reset](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-change-password)
23+
24+
The {{stack}} {{security-features}} only apply the `file` realm to the modified local node and do not apply changes across all nodes within the cluster. Administrators of self-managed deployments are responsible for ensuring one of the following:
25+
26+
* The same users and roles are defined across every node in the cluster.
27+
28+
Frequently, administrators choose to apply the change on one {{es}} node and then distribute or copy the files to all other nodes in the cluster. Files can be distributed either manually or using a configuration management system such as Puppet or Chef.
29+
* The related API requests are directed to the local node rather than to any cluster-level load balancer or proxy URL.
30+
31+
:::{tip}
32+
Refer to [enabling a file realm user for recovery](https://www.youtube.com/watch?v=sueO7sz1buw) for a video walkthrough of this process.
33+
:::
34+
35+
## Step 1 (Optional): Configure the realm [file-realm-recovery-configuration]
36+
37+
You don’t need to explicitly configure a `file` realm. The `file` and `native` realms are added to the realm chain by default. Unless configured otherwise, the `file` realm is added first, followed by the `native` realm. You can define only one `file` realm on each node.
38+
39+
To learn how to override the default `file` realm configuration, refer to [Configure a file realm](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/file-based#file-realm-configuration).
40+
41+
{{es}} reads security-related files upon the local node's initial startup and as periodically refreshed based on the `resource.reload.interval.high` setting. You do not need to restart nodes for changes to take effect. These files are located under the [`ES_PATH_CONF` directory](/deploy-manage/deploy/self-managed/configure-elasticsearch.md#config-files-location) and contain the following information:
42+
43+
* `roles.yml` for [defining roles](/deploy-manage/users-roles/cluster-or-deployment-auth/defining-roles.md)
44+
* `role_mapping.yml` for [mapping external users and groups to roles](/deploy-manage/users-roles/cluster-or-deployment-auth/mapping-users-groups-to-roles.md)
45+
* `users` for [user password-based authentication](/deploy-manage/users-roles/cluster-or-deployment-auth/user-authentication.md)
46+
* `user_roles` for [user role-based authorization](/deploy-manage/users-roles/cluster-or-deployment-auth/user-roles.md)
47+
48+
## Step 2: Choose roles for recovery [file-realm-recovery-roles]
49+
50+
Before granting a `file` realm user any roles, you need to ensure that those desired roles exist. You can use the following types of roles:
51+
52+
* [Built-in roles](elasticsearch://reference/elasticsearch/roles.md)
53+
* [Custom roles](/deploy-manage/users-roles/cluster-or-deployment-auth/defining-roles.md) defined under the {{stack}} {{security-features}}
54+
* Roles defined in [`roles.yml`](/deploy-manage/users-roles/cluster-or-deployment-auth/defining-roles.md#roles-management-file)
55+
56+
{{es}} recommends following the industry's [principle of least privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege) when granting user permissions. {{es}} follows this guidance itself by [restricting system indices](/deploy-manage/users-roles/cluster-or-deployment-auth/role-structure.md#roles-indices-priv) by default, even from [`superuser` role](elasticsearch://reference/elasticsearch/roles.md#available-roles) administrators including the [`elastic` built-in user](/deploy-manage/users-roles/cluster-or-deployment-auth/built-in-users.md).
57+
58+
The main {{stack}} {{security-features}} rely on the `security` [feature state](/deploy-manage/tools/snapshot-and-restore.md) which is mostly composed of the `.security*` [system indices](elasticsearch://reference/elasticsearch/rest-apis/api-conventions.md#system-indices). When recovering {{stack}} {{security-features}}, you will likely need to temporarily define a custom role with the [`allow_restricted_indices` setting](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-put-role) enabled.
59+
60+
For example, to grant the administrative privileges of `superuser` role alongside `allow_restricted_indices: true` you can create a new role called `superduperuser` with the following definition:
61+
62+
```yaml
63+
superduperuser:
64+
cluster: [ 'all' ]
65+
indices:
66+
- names: [ '*' ]
67+
privileges: [ 'all' ]
68+
allow_restricted_indices: true
69+
```
70+
71+
After you decide on your role definitions, you can add your users and any custom roles to your local node's configuration.
72+
73+
:::{{warning}}
74+
Restricted indices are a special category of indices that are used to store cluster configuration data and should not normally be directly accessed. **Toggling this flag is normally _strongly_ discouraged because it could effectively grant unrestricted operations on critical data, making the entire system unstable or leaking sensitive information.**
75+
76+
If `allow_restricted_indices` needs temporarily enabled for a user in order to recover the {{stack}} {{security-features}}, {{es}} recommends ensuring to remove this role with sensitive access from the user upon task completion.
77+
:::
78+
79+
## Step 3: Add the recovery user and role to the node [file-realm-recovery-files]
80+
81+
For most administrators, {{es}} recommends that you use the [`elasticsearch-users` tool](elasticsearch://reference/elasticsearch/command-line-tools/users-command.md), which compiles the `users` and `users_roles` files on your behalf.
82+
83+
In this example, we create an advanced administrative user with the `superduperuser` role we designed [in the previous step](#file-realm-recovery-roles).
84+
85+
::::{tab-set}
86+
87+
:::{tab-item} Self-managed
88+
89+
```
90+
bin/elasticsearch-users useradd admin -p changeme -r superduperuser
91+
```
92+
:::
93+
94+
:::{tab-item} ECK secrets
95+
The following is an example of invoking the `elasticsearch-users` tool in a Docker container:
96+
97+
```sh subs=true
98+
# create a folder with the 2 files
99+
mkdir filerealm
100+
touch filerealm/users filerealm/users_roles
101+
102+
# create user 'admin' with role 'superduperuser'
103+
docker run \
104+
-v $(pwd)/filerealm:/usr/share/elasticsearch/config \
105+
docker.elastic.co/elasticsearch/elasticsearch:{{version.stack}} \
106+
bin/elasticsearch-users useradd admin -p changeme -r superduperuser
107+
108+
# create a Kubernetes secret with the file realm content
109+
kubectl create secret generic my-file-realm-secret --from-file filerealm
110+
```
111+
112+
You can pass `users` and `user_roles` files to {{eck}} using a file realm secret:
113+
114+
```yaml subs=true
115+
apiVersion: elasticsearch.k8s.elastic.co/v1
116+
kind: Elasticsearch
117+
metadata:
118+
name: elasticsearch-sample
119+
spec:
120+
version: {{version.stack}}
121+
auth:
122+
fileRealm:
123+
- secretName: my-filerealm-secret-1
124+
- secretName: my-filerealm-secret-2
125+
nodeSets:
126+
- name: default
127+
count: 1
128+
```
129+
130+
A file realm secret is composed of two entries: a `users` entry and a `users_roles` entry. You can provide either one entry or both entries in each secret.
131+
132+
If you specify multiple users with the same name in more than one secret, the last one takes precedence. If you specify multiple roles with the same name in more than one secret, a single entry per role is derived from the concatenation of its corresponding users from all secrets.
133+
134+
The following secret specifies three users and their respective built-in and custom roles:
135+
136+
```yaml
137+
kind: Secret
138+
apiVersion: v1
139+
metadata:
140+
name: my-filerealm-secret
141+
stringData:
142+
roles.yml: |-
143+
superduperuser:
144+
cluster:
145+
- all
146+
indices:
147+
- names: [ '*' ]
148+
privileges: [ 'all' ]
149+
allow_restricted_indices: true
150+
users: |-
151+
rdeniro:$2a$10$BBJ/ILiyJ1eBTYoRKxkqbuDEdYECplvxnqQ47uiowE7yGqvCEgj9W
152+
alpacino:$2a$10$cNwHnElYiMYZ/T3K4PvzGeJ1KbpXZp2PfoQD.gfaVdImnHOwIuBKS
153+
jacknich:{PBKDF2}50000$z1CLJt0MEFjkIK5iEfgvfnA6xq7lF25uasspsTKSo5Q=$XxCVLbaKDimOdyWgLCLJiyoiWpA/XDMe/xtVgn1r5Sg=
154+
users_roles: |-
155+
admin:rdeniro
156+
superduperuser:alpacino,jacknich
157+
user:jacknich
158+
```
159+
:::
160+
161+
162+
:::{tab-item} ECK basic auth
163+
164+
You can also add `file` realm users using [{{k8s}} basic authentication secrets](https://kubernetes.io/docs/concepts/configuration/secret/#basic-authentication-secret). For more information, refer to [](/deploy-manage/users-roles/cluster-or-deployment-auth/file-based.md#k8s-basic).
165+
166+
1. Create a secret `my-roles-secret` that adds the `superduperuser` role definition:
167+
168+
```yaml
169+
apiVersion: v1
170+
kind: Secret
171+
metadata:
172+
name: my-roles-secret
173+
stringData:
174+
roles.yml: |-
175+
superduperuser:
176+
cluster:
177+
- all
178+
indices:
179+
- names: [ '*' ]
180+
privileges: [ 'all' ]
181+
allow_restricted_indices: true
182+
```
183+
184+
2. Set up a basic authentication secret `secret-basic-auth` which contains its `username`, `password`, and a comma-separated list of `roles`:
185+
186+
```yaml
187+
apiVersion: v1
188+
kind: Secret
189+
metadata:
190+
name: secret-basic-auth
191+
type: kubernetes.io/basic-auth
192+
stringData:
193+
username: admin # required field for kubernetes.io/basic-auth
194+
password: changeme # required field for kubernetes.io/basic-auth
195+
roles: superduperuser,superuser # optional, not part of kubernetes.io/basic-auth
196+
```
197+
198+
3. Make the secrets available to {{eck}} by adding them to your {{es}} manifest:
199+
200+
```yaml subs=true
201+
apiVersion: elasticsearch.k8s.elastic.co/v1
202+
kind: Elasticsearch
203+
metadata:
204+
name: elasticsearch-sample
205+
spec:
206+
version: {{version.stack}}
207+
auth:
208+
fileRealm:
209+
- secretName: secret-basic-auth
210+
roles:
211+
- secretName: my-roles-secret
212+
nodeSets:
213+
- name: default
214+
count: 1
215+
```
216+
217+
:::
218+
219+
::::
220+
221+
## Step 4: Recover {{security-features}} [file-realm-recovery-curl]
222+
223+
At this point, the local {{es}} node will accept [Elasticsearch API requests](https://www.elastic.co/docs/reference/elasticsearch/rest-apis) with the created `file` based username and password.
224+
225+
For example, if you created a user with the username `admin`, password `changeme`, and role `superduperuser`, then you can now send a cURL request to the [Get cluster info API](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-info) from the node's local shell:
226+
```bash
227+
curl -X GET -sk -u "admin:changeme" "https://localhost:9200/"
228+
```
229+
230+
:::{{tip}}
231+
The related API requests need to be directed to the local nodes where `file` has been configured, rather than to any cluster-level load balancer or proxy URL.
232+
:::
233+
234+
You can confirm that the desired `superduperuser` role is applied to your `admin` username using the [Authenticate a user API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-authenticate):
235+
```bash
236+
curl -X GET -sk -u "admin:changeme" "https://localhost:9200/_security/_authenticate?pretty=true"
237+
```
238+
239+
Now that you have regained recovery access to the cluster, you can investigate and recover the {{stack}} {{security-features}} as needed.

troubleshoot/toc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ toc:
5454
- file: elasticsearch/troubleshooting-searches.md
5555
- file: elasticsearch/start-ilm.md
5656
- file: elasticsearch/index-lifecycle-management-errors.md
57+
- file: elasticsearch/file-based-recovery.md
5758
- file: elasticsearch/security.md
5859
children:
5960
- file: elasticsearch/security/security-trb-settings.md

0 commit comments

Comments
 (0)