配置elasticsearch用windows account(AD)登录


参考文章:
• https://www.elastic.co/guide/en/elasticsearch/reference/current/active-directory-realm.html
• https://www.elastic.co/guide/en/elasticsearch/reference/current/security-settings.html#ref-ad-settings
• https://www.elastic.co/guide/en/elasticsearch/reference/current/elasticsearch-keystore.html

编辑es的配置文件

sudo vi /etc/eleicsearch/elasticsearch.yml

添加下面配置

xpack.security.authc.realms:
  native:
    native1:
      order: 1
  active_directory:
    my_ad:
      order: 0
      domain_name: domain
      url: ldaps://domain:port
      load_balance:
        type: "round_robin"
      bind_dn: "username@domain"
      ssl:
        certificate_authorities: [ "/etc/elasticsearch/certs/cacert.crt" ]
      user_search:
        base_dn: "DC=your_dc,DC=your_dc"
        filter: "(&(objectClass=user)(sAMAccountName={0}))"
      files:
        role_mapping: "/etc/elasticsearch/my_ad_role_mapping.yml"
      metadata:
        - cn
        - mail
        - displayName

替换domain成你的domain name
替换ldaps://domain:port成你的ldap服务器地址和端口
cacert.crt 替换成服务器的cacert
your_dc替换成你的DC

创建role mapping文件

Within a mapping definition, you specify groups using their distinguished names. For example, the following mapping configuration maps the Active Directory admins group to both the monitoring and user roles, maps the users group to the user role and maps the John Doe user to the user role.

monitoring: 
  - "cn=admins,dc=example,dc=com" 
user:
  - "cn=users,dc=example,dc=com" 
  - "cn=admins,dc=example,dc=com"
  - "cn=John Doe,cn=contractors,dc=example,dc=com" 

The name of the role.

The Active Directory distinguished name (DN) of the admins group.

The Active Directory distinguished name (DN) of the users group.

The Active Directory distinguished name (DN) of the user John Doe.

添加windows account的密码

sudo /usr/share/elasticsearch/bin/elasticsearch-keystore add xpack.security.authc.realms.active_directory.my_ad.secure_bind_password

然后输入密码,回车
输入下面的命令去查看刚刚的密码是否正确。

sudo /usr/share/elasticsearch/bin/elasticsearch-keystore show xpack.security.authc.realms.active_directory.my_ad.secure_bind_password

给role mapping和cacert文件正确的权限

sduo chmod 755 
sudo chowm elastinsearch /etc/elasticsearch/certs/cacert.crt
sduo chmod 755 /etc/elasticsearch/my_ad_role_mapping.yml
sudo chowm elastinsearch /etc/elasticsearch/my_ad_role_mapping.yml

重启kibana和elasticsearch

sudo systemctl restart kibana
sudo systemctl restart elasticseatch

在kibana页面登陆elasticsearch

在这里插入图片描述
可以看到成功登录了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值