zoukankan      html  css  js  c++  java
  • ElasticSearch+Kibana设置用户名密码登陆

    ElasticSearch版本:7.7.1

    配置

    修改es的配置文件:elasticsearch.yml,添加如下配置

    xpack.security.enabled: true
    xpack.license.self_generated.type: basic
    xpack.security.transport.ssl.enabled: true
    

    es的bin目录下,执行设置用户名和密码的命令

    ./elasticsearch-setup-passwords interactive
    

    这里会设置六个账号的密码:elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.

    image-20210425122400164

    修改kibana的配置kibana.yml

    image-20210425123351140

    es修改密码的命令如下:

    curl -H "Content-Type:application/json" -XPOST -u elastic 'http://192.168.140:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
    

    重启es和kibana

    访问http://192.168.1.40:9200,需要输入账号密码才可以访问

    image-20210425123533151

    访问:http://192.168.1.40:5601/

    同样需要认证才可登陆,登陆账号密码为elastic/123456

    image-20210425123637430

    java客户端连接

    需要与springdata es整合

    RestHighLevelClient

        @Bean
        public RestHighLevelClient restHighLevelClient() {
    
            final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
                    .connectedTo("192.168.1.40:9200")
                    .withConnectTimeout(Duration.ofSeconds(5))
                    .withSocketTimeout(Duration.ofSeconds(3))
                    .withBasicAuth("elastic", "123456")
                    .build();
            return RestClients.create(clientConfiguration).rest();
        }
    

    SpringData ES配置

    spring:
      elasticsearch:
        rest:
          uris: "http://192.168.1.40:9200"
          read-timeout: "10s"
          username: "elastic"
          password: "123456"
          connection-timeout: "10s"
    
  • 相关阅读:
    AD域渗透测试笔记
    ctf之WEB练习一
    CTF之crpto练习三
    ctf之WEB练习二
    ctf之WEB练习三
    [转]Ant学习笔记——自己构建Ant编译环境
    [转]【NoSQL】NoSQL入门级资料整理(CAP原理、最终一致性)
    啥叫异步调用
    C++中虚函数的作用是什么?它应该怎么用呢?
    [转]Thrift连接池实现
  • 原文地址:https://www.cnblogs.com/wwjj4811/p/14700279.html
Copyright © 2011-2022 走看看