# ElasticsearchSecurityException: 缺少身份验证凭据 [全局]

- **ID:** `elasticsearch/missing-authentication-credentials`
- **领域:** elasticsearch
- **类别:** auth_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

对 Elasticsearch 的请求缺少必要的身份验证凭据，通常是由于缺少 API 密钥或令牌。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.17.0 | active | — | — |
| 8.10.0 | active | — | — |
| 8.14.0 | active | — | — |

## 解决方案

1. ```
   通过 Kibana 或 `POST /_security/api_key` 端点生成新的 API 密钥，并将其包含在 `Authorization` 头中：`Authorization: ApiKey <base64编码的密钥>`。
   ```
2. ```
   在请求中使用有效的用户名和密码：`curl -u username:password https://localhost:9200/_cluster/health`。
   ```
3. ```
   使用服务账户令牌配置客户端：`PUT _security/service/elastic/kibana/credential/token`，并在请求中使用。
   ```

## 无效尝试

- **** — Disabling security exposes the cluster to unauthorized access and is not a proper fix. (70% 失败率)
- **** — Restarting does not provide the missing credentials; the error will recur. (95% 失败率)
- **** — The client still uses old credentials, causing authentication failure. (90% 失败率)
