[OpenDistro] OpenDistro for Elasticsearch 教程之【安全模块】

目录

前言

为什么使用opendistro???

安装

下载zip包

安装插件

配置

后端配置

TLS配置

生成证书

使用securityadmin.sh应用配置更改

以上就是OpenDistro for Elasticsearch 安全模块教程,具体elasticsearch使用openDistro插件添加kerberos安装配置,请跳转到此页面


前言

Open Distro for ElasticsearchElasticsearch的增值发行版,它是100%开源(Apache 2.0许可)并受AWS支持。用于Elasticsearch的Open Distro利用Elasticsearch和Kibana的开源代码。

除了Elasticsearch和Kibana之外,该版本还包含一组高级安全性,事件监视和警报,性能分析以及SQL查询功能。除了源代码存储块之外,Open Distro for Elasticsearch和Kibana还可以作为RPM,Debian软件包和Docker容器使用,并且可以分别下载SQL JDBC和PerfTop CLI。您可以在笔记本电脑,数据中心或云中运行此代码。 ------来自amazon的官方介绍

为什么使用opendistro???

elasticsearch 要用kerberos最少要白金版啊,破解自己玩玩儿还行,一个大公司可不能这么用。 这种100%开源的插件最符合,像search-guard也要企业版才能用kerberos功能。。。。。 

有很多版本,我这次安装的是最新版本,es也选择的7.10.2 ,opendistro-security 1.13.1.0

  • 安装方式有docker、rpm、自己下载zip包,我选择自己下载插件zip包

安装

下载zip包

https://d3g5vo6xdbdb9a.cloudfront.net/downloads/elasticsearch-plugins/opendistro-security/opendistro-security-1.13.1.0.zip

安装插件

[root@henghe-052 elasticsearch]# bin/elasticsearch-plugin install file:///opt/opendistro-security-1.13.1.0.zip

进入到plugin,就能看到了

[root@henghe-052 elasticsearch]# cd plugins/

配置

后端配置

confg.xml有三个主要的部分

opendistro_security

     dynamic:

          http:

            ...

         authc:

            ...

         authz

            ...

config.xml位置

  • HTTP

anonymous_auth_enabled: true  #为true代表开启匿名身份验证,开启后authc,也就是配置的authc下面的不起作用了

  • Authentication

 http_enabled: true
 transport_enabled: true
 order: 0

authc部分中的条目称为身份验证域。它指定从何处获取用户凭证以及应针对哪个后端对其进行身份验证。

您可以使用多个身份验证域。每个身份验证域都有一个名称(例如basic_auth_internal),enabled标志和一个order。该顺序使将身份验证域链接在一起成为可能。安全插件将按照您提供的顺序使用它们。如果用户成功通过一个域进行身份验证,则安全插件将跳过其余域。

http_authenticator 指定要在HTTP层上使用的身份验证方法。

这是在HTTP层上定义身份验证器的语法:

http_authenticator:
          type: <type>
          challenge: <true|false>
          config:
          ...

这些是以下允许的值type

  • basic:HTTP基本身份验证。无需其他配置。
  • kerberos:Kerberos身份验证。需要其他特定于kerberos的配置。
  • jwt:JSON Web令牌认证。需要其他腾定于JWT的配置。
  • clientcert:通过客户端TLS证书进行身份验证。节点的信任库中的根CA必须信任此证书。
  • Authorization
 authc:
      <name>:
        http_enabled: <true|false>
        transport_enabled: <true|false>
        authentication_backend:
          type: <type>
          config:
          ...

这些是以下各项的可能值type

  • noop:完全跳过此步骤。
  • ldap:从LDAP服务器获取其他角色。此设置需要其他特定于LDAP的配置设置
  • Kerberos

1.要在elasticsearch.yml中添加krb5文件位、keytab位置、principal

opendistro_security.kerberos.krb5_filepath: '/etc/krb5.conf'
opendistro_security.kerberos.acceptor_keytab_filepath: 'http.keytab'
opendistro_security.kerberos.acceptor_principal: 'HTTP/henghe-052'

2.修改config.yml

    authc:
      kerberos_auth_domain:
        http_enabled: true
        transport_enabled: true
        order: 0
        http_authenticator:
          type: kerberos
          challenge: true
          config:
            # If true a lot of kerberos/security related debugging output will be logged to standard out
            krb_debug: true
            # If true then the realm will be stripped from the user name
            strip_realm_from_principal: true
        authentication_backend:
          type: noop

其中challenge设置为true,设置为false,安全插件没有办法在请求中获取凭证

由于Kerberos / SPNEGO在HTTP级别上对用户进行身份验证,因此不需要其他authentication_backend操作。将此值设置为noop

  • JSON web token

暂时没研究

TLS配置

X.509 PEM证书和PKCS#8密钥

Transport layer TLS

生成证书

  • centOS上,使用yum
sudo yum install openssl
  • 样例脚本
# Root CA
openssl genrsa -out root-ca-key.pem 2048
openssl req -new -x509 -sha256 -key root-ca-key.pem -out root-ca.pem -days 30
# Admin cert
openssl genrsa -out admin-key-temp.pem 2048
openssl pkcs8 -inform PEM -outform PEM -in admin-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out admin-key.pem
openssl req -new -key admin-key.pem -out admin.csr
openssl x509 -req -in admin.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out admin.pem -days 30
# Node cert
openssl genrsa -out node-key-temp.pem 2048
openssl pkcs8 -inform PEM -outform PEM -in node-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out node-key.pem
openssl req -new -key node-key.pem -out node.csr
openssl x509 -req -in node.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out node.pem -days 30
#Client cert
openssl genrsa -out client-key-temp.pem 2048
openssl pkcs8 -inform PEM -outform PEM -in client-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out client-key.pem
openssl req -new -key client-key.pem -out client.csr
openssl x509 -req -in client.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out client.pem -days 30
# Cleanup
rm admin-key-temp.pem
rm admin.csr
rm node-key-temp.pem
rm node.csr
rm client-key-temp.pem
rm client.csr

如果创建了管理证书和节点证书,则必须elasticsearch.yml在所有节点上指定其专有名称(DN):

opendistro_security.authcz.admin_dn:
  - 'CN=ADMIN,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'
opendistro_security.nodes_dn:
  - 'CN=node1.example.com,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'
  - 'CN=node2.example.com,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'

但是,如果subject在创建证书后查看证书的,则可能会看到不同的格式:

subject=/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=node1.example.com

如果将此字符串与elasticsearch.yml上面的字符串进行比较,可以看到需要反转元素的顺序并使用逗号而不是斜杠。输入以下命令以获取正确的字符串:

openssl x509 -subject -nameopt RFC2253 -noout -in node.pem

然后,您可以将输出复制并粘贴到elasticsearch.yml

subject= CN=node1.example.com,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA

使用securityadmin.sh应用配置更改

官网写的很详细Apply Changes with securityadmin.sh - Open Distro Documentation

以上就是OpenDistro for Elasticsearch 安全模块教程,具体elasticsearch使用openDistro插件添加kerberos安装配置,请跳转到此页面

Chapter 1, Introduction to DevOps, walks you through the evolution from the past to what we call DevOps today and the tools that you should know. Demand for people with DevOps skills has been growing rapidly over the last few years. It has accelerated software development and delivery speed and has also helped business agility. Chapter 2, DevOps with Container, helps you learn the fundamentals and container orchestration. With the trend of microservices, container has been a handy and essential tool for every DevOps because of its language agnostic isolation. Chapter 3, Getting Started with Kubernetes, explores the key components and API objects in Kubernetes and how to deploy and manage containers in a Kubernetes cluster. Kubernetes eases the pain of container orchestration with a lot of killer features, such as container scaling, mounting storage systems, and service discovery. Chapter 4, Working with Storage and Resources, describes volume management and also explains CPU and memory management in Kubernetes. Container storage management can be hard in a cluster. Chapter 5, Network and Security, explains how to allow inbound connection to access Kubernetes services and how default networking works in Kubernetes. External access to our services is necessary for business needs. Chapter 6, Monitoring and Logging, shows you how to monitor a resource's usage at application, container, and node level using Prometheus. This chapter also shows how to collect logs from your applications, as well as Kubernetes with Elasticsearch, Fluentd, and Kibana stack. Ensuring a service is up and healthy is one of the major responsibilities of DevOps. Chapter 7, Continuous Delivery, explains how to build a Continuous Delivery pipeline with GitHub/DockerHub/TravisCI. It also explains how to manage updates, eliminate the potential impact when doing rolling updates, and prevent possible failure. Continuous Delivery is an approach to speed up your time-to-market. Chapter 8, Cluster Administration, describes how to solve the preceding problems with the Kubernetes namespace and ResourceQuota and how to do access control in Kubernetes. Setting up administrative boundaries and access control to Kubernetes cluster are crucial to DevOps. Chapter 9, Kubernetes on AWS, explains AWS components and shows how to provision Kubernetes on AWS. AWS is the most popular public cloud. It brings the infrastructure agility and flexibility to our world. Chapter 10, Kubernetes on GCP, helps you understand the difference between GCP and AWS, and the benefit of running containerized applications in hosted service from Kubernetes’ perspective. Google Container Engine in GCP is a managed environment for Kubernetes. Chapter 11, What’s Next?, introduces other similar technologies, such as Docker Swarm mode, Amazon ECS, and Apache Mesos and you’ll have an understanding of which the best approach is for your business. Kubernetes is open. This chapter will teach you how to get in touch with Kubernetes community to learn ideas from others.
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值