logo

ELK-elasticsearch设置用户、添加新用户、以及对应密码修改

作者:谁偷走了我的奶酪2024.01.18 02:04浏览量:27

简介:本文将指导您如何为ELK(Elasticsearch、Logstash和Kibana)中的Elasticsearch设置用户、添加新用户,以及如何修改用户密码。

在ELK中,Elasticsearch是最核心的部分,它负责数据的存储和检索。为了安全起见,您可能需要为Elasticsearch设置用户并控制访问权限。以下是设置用户、添加新用户以及修改密码的步骤:
1. 设置用户
首先,您需要创建一个新的用户。在Linux系统中,可以使用useradd命令来创建新用户。例如,要创建一个名为elastic的用户,可以运行以下命令:

  1. useradd elastic

然后,您需要为该用户设置密码。可以使用passwd命令来完成这一操作:

  1. passwd elastic

按照提示输入新密码两次即可。
2. 添加新用户到Elasticsearch
默认情况下,Elasticsearch运行时会以elastic用户身份运行。为了允许新用户访问Elasticsearch,您需要将该用户添加到Elasticsearch的配置文件中。
打开Elasticsearch的配置文件elasticsearch.yml,通常位于/etc/elasticsearch/目录下。在该文件中,找到以下行:

  1. xpack.security.enabled: true

确保该行已启用(即设置为true)。然后,在该文件的末尾添加以下行:

  1. xpack.security.transport.ssl.enabled: true
  2. xpack.security.transport.ssl.verification_mode: certificate
  3. xpack.security.transport.ssl.keystore.path: certs/elastic.p12
  4. xpack.security.transport.ssl.truststore.path: certs/elastic.p12

保存并关闭文件。接下来,您需要为新用户生成证书。运行以下命令:

  1. bin/elasticsearch-certutil user --pem -name elastic_new

这将生成一个名为elastic_new.pem的证书文件。将此证书文件复制到Elasticsearch的配置目录中:

  1. cp elastic_new.pem /etc/elasticsearch/certs/elastic_new.pem

然后,将新用户的证书添加到Elasticsearch的信任存储库中:
```bash
bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.password
bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.password
bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.path /etc/elasticsearch/certs/elastic_new.pem truststore_path certs/elastic_new.pem keystore_password elastic_new keystore_password elastic_new truststore_password elastic_new truststore_password elastic_new keystore_type PKCS12 keystore_type PKCS12 truststore_type PKCS12 truststore_type PKCS12 force yes force yes yes yes yes no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyes

相关文章推荐

发表评论