ES_如何设置ElasticSearch 8.0版本的匿名访问以及https_http模式的互相切换

总结:
设置匿名访问,只需要设置xpack.security.authc.anonymous.username和xpack.security.authc.anonymous.roles参数就行,设置好后,可以匿名访问也可以非匿名访问,但是非匿名访问的情况下必须保证用户名和密码正确
取消https模式即取消TLS只用http的情况下,必须xpack.security.enabled和xpack.security.http.ssl.enabled和xpack.security.transport.ssl.enabled三个参数一起设置为false,这种模式下,不管是否设置匿名访问,都可以匿名访问,也可以非匿名访问并且用户名和密码错误也可以访问,也就是说取消https模式即取消TLS只用http的情况下,是完全的不要认证更不会管是否匿名访问还是不匿名访问了

ES如果直接不需要输入账号密码就能实现curl查询集群状态的话,那么可以使用设置匿名访问的方式,在三个节点上的/etc/elasticsearch/elasticsearch.yml设置下面2个参数,以实现匿名访问
xpack.security.authc.anonymous.username: anonymous_user
The username (principal) of the anonymous user. Defaults to _es_anonymous_user.
匿名用户的用户名(主体)

xpack.security.authc.anonymous.roles: superuser
The roles to associate with the anonymous user. Required.
与匿名用户关联的角色。必需的。

下面3个参数设置与否对匿名访问没有影响
xpack.security.authc.token.enabled: false
Set to false to disable the built-in token service. Defaults to true unless xpack.security.http.ssl.enabled is false. This prevents sniffing the token from a connection over plain http.
设置为 false 以禁用内置令牌服务。默认为 true,除非 xpack.security.http.ssl.enabled 为 false。这可以防止通过普通http连接嗅探令牌

xpack.security.http.ssl.client_authentication
Controls the server’s behavior in regard to requesting a certificate from client connections. Valid values are required, optional, and none. required forces a client to present a certificate, while optional requests a client certificate but the client is not required to present one. Defaults to none.
控制服务器在从客户端连接请求证书方面的行为。有效值是必需的、可选的和无。必需的强制客户端提供证书,而可选的则请求客户端证书但不要求客户端提供证书。默认为无。
–这个参数不是说配置为none就是客户端浏览器不用输入账号密码就能访问,而是说客户端浏览器访问服务器web时,服务器web端是否也需要客户端浏览器提供证书才能允许客户端浏览器连接服务器web端,就类似网银一样客户端那边的浏览器需要安装控件什么的才能正常访问银行网站。

xpack.security.authc.anonymous.authz_exception
When true, an HTTP 403 response is returned if the anonymous user does not have the appropriate permissions for the requested action. The user is not prompted to provide credentials to access the requested resource. When set to false, an HTTP 401 response is returned and the user can provide credentials with the appropriate permissions to gain access. Defaults to true.
如果为 true,则如果匿名用户没有所请求操作的适当权限,则会返回 HTTP 403 响应。系统不会提示用户提供访问所请求资源的凭据。当设置为 false 时,将返回 HTTP 401 响应,并且用户可以提供具有适当权限的凭据来获取访问权限。默认为 true。

设置如下

xpack.security.authc.anonymous.username: anonymous_user
xpack.security.authc.anonymous.roles: superuser

验证结果,用密码和不用密码都可以正常访问,但是用错误密码无法访问

root@woncnesdbtest1:~# curl -XGET "https://woncnesdbtest1:9200/_cat/health?v" -k
root@woncnesdbtest1:~# curl -XGET -uelastic:rightpassword "https://woncnesdbtest1:9200/_cat/health?v" -k
root@woncnesdbtest1:~# curl -XGET -uelastic:wrongpassword "https://woncnesdbtest1:9200/_cat/health?v" -k
{"error":{"root_cause":[{"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/_cat/health?v]","header":{"WWW-Authenticate":["Basic realm=\"security\", charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}}],"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/_cat/health?v]","header":{"WWW-Authenticate":["Basic realm=\"security\", charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}},"status":401}

如何设置http,即如何取消https,只需要把下面三个参数设置为false并重启即可

xpack.security.enabled: false
xpack.security.http.ssl:enabled: false
xpack.security.transport.ssl:enabled: false

xpack.security.enabled
(Static) Defaults to true, which enables Elasticsearch security features on the node. This setting must be enabled to use Elasticsearch’s authentication, authorization and audit features.
默认为 true,这会在节点上启用 Elasticsearch 安全功能。必须启用此设置才能使用 Elasticsearch 的身份验证、授权和审核功能。

xpack.security.http.ssl.enabled
(Static) Used to enable or disable TLS/SSL on the HTTP networking layer, which Elasticsearch uses to communicate with other clients. The default is false.
用于启用或禁用 HTTP 网络层上的 TLS/SSL,Elasticsearch 使用该网络层与其他客户端进行通信。默认为 false。

xpack.security.transport.ssl.enabled
(Static) Used to enable or disable TLS/SSL on the transport networking layer, which nodes use to communicate with each other. The default is false.
用于启用或禁用传输网络层上的 TLS/SSL,节点使用该层相互通信。默认为 false。

如果只是xpack.security.transport.ssl.enabled把设置为false,但是xpack.security.enabled还是true会有如下报错
bootstrap check failure [1] of [1]: Transport SSL must be enabled if security is enabled. Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting [xpack.security.enabled] to [false]; for more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.17/bootstrap-checks-xpack.html#bootstrap-checks-tls]

设置为不启用SSL并且非匿名访问,发现最后还是可以匿名访问并且非匿名访问时用错误的密码可以正常连接

xpack.security.enabled: false
xpack.security.http.ssl:enabled: false
xpack.security.transport.ssl:enabled: false
#xpack.security.authc.anonymous.username: anonymous_user
#xpack.security.authc.anonymous.roles: superuser

验证

root@woncnesdbtest1:~# curl -XGET "https://woncnesdbtest1:9200/_cat/health?v" -k
curl: (35) error:0A00010B:SSL routines::wrong version number
root@woncnesdbtest1:~# 
root@woncnesdbtest1:~# curl -XGET -uelastic:rightpassword "https://woncnesdbtest1:9200/_cat/health?v" -k
curl: (35) error:0A00010B:SSL routines::wrong version number
root@woncnesdbtest1:~# 
root@woncnesdbtest1:~# curl -XGET "http://woncnesdbtest1:9200/_cat/health?v" -k
epoch      timestamp cluster          status node.total node.data shards pri relo init unassign unassign.pri pending_tasks max_task_wait_time active_shards_percent
1735899387 10:16:27  dailaesdbcluster green           4         4     14   6    0    0        0            0             0                  -                100.0%
root@woncnesdbtest1:~# 
root@woncnesdbtest1:~# curl -XGET -uelastic:rightpassword "http://woncnesdbtest1:9200/_cat/health?v" -k
epoch      timestamp cluster          status node.total node.data shards pri relo init unassign unassign.pri pending_tasks max_task_wait_time active_shards_percent
1735899393 10:16:33  dailaesdbcluster green           4         4     14   6    0    0        0            0             0                  -                100.0%
root@woncnesdbtest1:~# 
root@woncnesdbtest1:~# curl -XGET -uelastic:wrongpassword "http://woncnesdbtest1:9200/_cat/health?v" -k
epoch      timestamp cluster          status node.total node.data shards pri relo init unassign unassign.pri pending_tasks max_task_wait_time active_shards_percent
1735899409 10:16:49  dailaesdbcluster green           4         4     14   6    0    0        0            0             0                  -                100.0%

设置为不启用SSL并且匿名访问,发现最后还是可以匿名访问并且非匿名访问时用错误的密码可以正常连接

xpack.security.enabled: false
xpack.security.http.ssl:enabled: false
xpack.security.transport.ssl:enabled: false
xpack.security.authc.anonymous.username: anonymous_user
xpack.security.authc.anonymous.roles: superuser

验证

root@woncnesdbtest1:~# curl -XGET "https://woncnesdbtest1:9200/_cat/health?v" -k
curl: (35) error:0A00010B:SSL routines::wrong version number
root@woncnesdbtest1:~#
root@woncnesdbtest1:~# curl -XGET -uelastic:rightpassword "https://woncnesdbtest1:9200/_cat/health?v" -k
curl: (35) error:0A00010B:SSL routines::wrong version number
root@woncnesdbtest1:~#
root@woncnesdbtest1:~# curl -XGET "http://woncnesdbtest1:9200/_cat/health?v" -k
epoch      timestamp cluster          status node.total node.data shards pri relo init unassign unassign.pri pending_tasks max_task_wait_time active_shards_percent
1735900832 10:40:32  dailaesdbcluster green           4         4     14   6    0    0        0            0             0                  -                100.0%
root@woncnesdbtest1:~#
root@woncnesdbtest1:~# curl -XGET -uelastic:rightpassword "http://woncnesdbtest1:9200/_cat/health?v" -k
epoch      timestamp cluster          status node.total node.data shards pri relo init unassign unassign.pri pending_tasks max_task_wait_time active_shards_percent
1735900849 10:40:49  dailaesdbcluster green           4         4     14   6    0    0        0            0             0                  -                100.0%
root@woncnesdbtest1:~#
root@woncnesdbtest1:~# curl -XGET -uelastic:wrongpassword "http://woncnesdbtest1:9200/_cat/health?v" -k
epoch      timestamp cluster          status node.total node.data shards pri relo init unassign unassign.pri pending_tasks max_task_wait_time active_shards_percent
1735900861 10:41:01  dailaesdbcluster green           4         4     14   6    0    0        0            0             0                  -                100.0%
root@woncnesdbtest1:~#

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/65405.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

uni-app深度解码:跨平台APP开发的核心引擎与创新实践

在当今数字化浪潮中,移动应用市场呈现出爆炸式增长。为了满足不同用户群体在不同操作系统上的需求,跨平台 APP 开发成为众多开发者的首选策略。uni-app 作为一款领先的跨平台开发框架,以其独特的优势和创新的实践在众多同类产品中脱颖而出。它…

oxml中创建CT_Document类

概述 本文基于python-docx源码,详细记录CT_Document类创建的过程,以此来加深对Python中元类、以及CT_Document元素类的认识。 元类简介 元类(MetaClass)是Python中的高级特性。元类是什么呢?Python是面向对象编程…

FastGPT 介绍

FastGPT 是一种专注于高效对话和任务处理的人工智能语言模型。以下是关于 FastGPT 的一些主要特性和应用场景: FastGPT 的特点: 速度与效率: FastGPT 经过优化,能够以更快的速度生成高质量的内容,适用于对实时性要求较…

jenkins入门6 --拉取代码

Jenkins代码拉取 需要的插件,缺少的安装下 新建一个item,选择freestyle project 源码管理配置如下:需要添加git库地址,和登录git的用户密码 配置好后执行编译,成功后拉取的代码在工作空间里

CE中注册的符号地址如何通过编程获取

我的方式是先执行lua申请共享内存,内存名称是进程id,这样多开也不受影响,然后通过共享内存的名字就可以读到地址了。之后的人造指针的地址也都可以放这里集中管理。 -- 申请内存 local size 1024 -- 申请 1024 字节(1 KB&#…

在 ASP.NET CORE 中上传、下载文件

创建 Web API 来提供跨客户端和服务器的文件上传和下载是常有的事。本文将介绍如何通过 ASP.NET CORE 来实现。 首先在 Visual Studio 中创建空的 Web API 项目,然后选择目标框架 .Net Core 3.1。 创建名为 FileController 的控制器,提供操作文件的接口…

vue2迁移至rsbuild

背景 由于远程机器配置较低,每次运行vue2项目都会非常卡。后期项目文件、路由更多的时候,启动到一半直接会跳出open too many files类似的错误,尝试将路由屏蔽掉只剩下开发所需的一个路由也不行(不是说webpack的打包是全部打包&am…

智能手机租赁系统全新模式改变消费习惯与商家盈利路径

内容概要 智能手机租赁系统的崛起,让我们瞄到了一个消费市场的新风向标。想象一下,传统上人们总是为了最新款手机奋不顾身地排队、借钱甚至是透支信用卡。现在,通过灵活的租赁选项,消费者可以更加随意地体验高科技产品&#xff0…

[项目实战2]贪吃蛇游戏

目录 贪吃蛇游戏:: 一、游戏效果及功能实现: 1.规则 ​​​​​​​ ​​​​​​​ ​​​​​​​ 2.基本功能实现 ​​​​​​​ ​​​​​​​ ​​​​​​​ 3.技术要点 ​​​​​​​…

浏览器报错:您的连接不是私密连接,Kubernetes Dashboard无法打开

问题描述 部署完成Kubernetes Dashboard后,打开HTTPS的web页面,Chrome和Edge浏览器都无法正常加载页面,会提示您的连接不是私密连接的报错。 ​​​​​​​​​​​​ 原因: 浏览器不信任这些自签名的ssl证书,为了…

关于量子神经网络的思考

其实在写这篇文章之前想了很多,主要是想法太超前,有可能颠覆未来机器智能行业甚至是影响世界。 1、计算机的历史 计算机的历史可以追溯到20世纪中叶,最早的电子计算机如ENIAC和EDVAC采用了冯诺依曼架构(John von Neumann Archit…

docker pull(拉取镜像)的时候,无法下载或者卡在Waiting的解决方法

docker pull的时候,卡在Waiting的解决方法 一般情况(大部分镜像都可以拉取)更换镜像源 进一步(如es等拉取不到)在镜像同步站搜索详细步骤 还可以在挂载的时候,让其下载对应的版本 一般情况(大部…

PHP二维数组去除重复值

Date: 2025.01.07 20:45:01 author: lijianzhan PHP二维数组内根据ID或者名称去除重复值 代码示例如下: // 假设 data数组如下 $data [[id > 1, name > Type A],[id > 2, name > Type B],[id > 1, name > Type A] // 重复项 ];// 去重方法 $dat…

注册中心如何选型?Eureka、Zookeeper、Nacos怎么选

这是小卷对分布式系统架构学习的第9篇文章,第8篇时只回答了注册中心的工作原理的内容,面试官的第二个问题还没回答,今天再来讲讲各个注册中心的原理,以及区别,最后如何进行选型 上一篇文章:如何设计一个注册…

SQL使用视图

本文将介绍什么是视图,它们怎样工作,何时使用它们。 1. 视图 视图是虚拟的表。与包含数据的表不一样,视图只包含使用时动态检索数据的查询。 说明:SQLite 的视图 SQLite 仅支持只读视图,所以视图可以创建&#xff…

Three.js - 打开Web 3D世界的大门

文章目录 前言一、Three.js 的起源与背景二、Three.js 的特点三、Three.js 的核心组件详解四、实际应用案例结语 前言 Three.js 是一个基于JavaScript的库,它极大地简化了使用WebGL创建3D图形的过程。通过封装复杂的WebGL API,Three.js为开发者提供了一…

恒压恒流原边反馈控制芯片 CRE6289F

CRE6289F 系列产品是一款内置高压 MOS 功率开关管的高性能多模式原边控制的开关电源芯片。较少的外围元器件、较低的系统成本设计出高性能的交直流转换开关电源。CRE6289F 系列产品提供了极为全面和性能优异的智能化保护功能,包括逐周期过流保护、软启动、芯片过温保…

开源 AI 智能名片 2+1 链动模式商城小程序在商业营销中的心理博弈与策略应用

摘要:在当今竞争激烈的商业环境中,理解消费者心理对营销成败起着关键作用。本文聚焦于消费者 “占便宜” 心理,深入探讨开源 AI 智能名片 21 链动模式商城小程序如何利用这一心理,在 “双十一”“双十二” 等购物热潮背景下&#…

01 数据分析介绍及工具准备

数据分析介绍及工具准备 一、工具准备二、下载和使用Anaconda三、jupyter notebook常用快捷键 一、工具准备 数据科学库 NumPy,SciPy,Pandas,Scikit-Learn 数据可视化库 Matplotlib,Seaborn 编译器 Jupyter Notebook 数据科…

opencv摄像头标定程序实现

摄像头标定是计算机视觉中的一个重要步骤,用于确定摄像头的内参(如焦距、主点、畸变系数等)和外参(如旋转矩阵和平移向量)。OpenCV 提供了方便的工具来进行摄像头标定。下面分别给出 C 和 Python 的实现。 1. C 实现…