一、概述

1、etcd的v2和v3的认证有些不同,需要分别设置
2、Etcd通过用户(user)-角色(role)-权限的方式来控制访问,用户关联角色,角色拥有权限,从而用户也就拥有了相应的权限
3、Etcd开启Basic Auth之后,默认会启用两个角色root和guest,root角色拥有所有权限,guest拥有只读权限,这两个角色都不要删除

二、授权

v2:
1、添加root,创建root后,root默认有root最高权限
etcdctl --endpoints=http://127.0.0.1:2379 user add root

2、开启认证
etcdctl --endpoints=http://127.0.0.1:2379 auth enable

3、添加一个读写账号和一个只读账号
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 user add reado
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 user add readw

4、添加只读角色和读写角色
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 role add readConf
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 role add rootConf

5、为角色授权
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 grant --read --path /* readConf
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 grant --readwrite --path /* rootConf

6、为用户分配角色
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 user grant --roles readConf reado
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 user grant --roles rootConf readw

7、常用命令
1)关闭auth
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 auth disable

2)删除用户
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 user remove reado

3)用户撤销角色
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 user revoke --roles readConf reado

4)修改用户密码
etcdctl --endpoints=http://127.0.0.1:2379 --username root:123456 user passwd reado

v3:
1、添加root,创建root后,root默认有root最高权限
etcdctl --endpoints=http://127.0.0.1:2379 user add root

2、创建普通用户
etcdctl --endpoints=http://127.0.0.1:2379 --user=root:123456 user add putong

3、添加角色
etcdctl --endpoints=http://127.0.0.1:2379 --user=root:123456 role add normal

4、角色授权
etcdctl --endpoints=http://127.0.0.1:2379 --user=root:123456 role grant-permission --prefix=true normal readwrite /path_name

5、用户绑定角色
etcdctl --endpoints=http://127.0.0.1:2379 --user=root:123456 user grant-role putong normal

etcd 开启auth认证的更多相关文章

  1. Etcd安全配置之Basic Auth认证

    <中小团队落地配置中心详解>文章中我们介绍了如何基于Etcd+Confd构建配置中心,最后提到Etcd的安全问题时说了可以使用账号密码认证以达到安全访问的目的,究竟该如何开启认证以及怎么设 ...

  2. CentOS6.8部署MongoDB集群及支持auth认证

    三个节点的副本集如下图所示: 实验目的: 配置MongoDB的3节点副本集 3个节点的副本集都要开启auth认证,并且开启认证后,能互相通信 第一步 - 准备环境 准备三个虚拟机,其中一个用作Prim ...

  3. MongDB开启权限认证

    在生产环境中MongoDB已经使用有一段时间了,但对于MongoDB的数据存储一直没有使用到权限访问(MongoDB默认设置为无权限访问限制),最近在酷壳网看了一篇技术文章(https://cools ...

  4. Docker Mongo数据库开启用户认证

    一.启动mongo容器的几种方式 #简化版 docker run --name mongo1 -p 21117:27017 -d mongo --noprealloc --smallfiles #自定 ...

  5. MongoDB开启权限认证

      MongoDB默认安装完后,如果在配置文件中没有加上auth = true,是没有用户权限认证的,这样对于一个数据库来说是相对不安全的,尤其是在外网的情况下. 接下来是配置权限的过程: //切入到 ...

  6. mongodb复制集开启安全认证

    之前我有一篇博客写的是“node.js通过权限验证连接MongoDB”,这篇博客上提到如何在启动文件中通过配置auth参数来开启权限认证,但这种认证方式只适合单机节点,当我们使用复制集时应该怎么开启权 ...

  7. MongoDB开启安全认证

    MongoDB开启安全认证 注意 对MongoDB部署启用访问控制会强制执行身份验证,要求用户识别自己.当访问启用了访问控制的MongoDB部署时,用户只能执行由其角色确定的操作. 启用访问控制后,请 ...

  8. mongodb分片集群开启安全认证

    原文地址:https://blog.csdn.net/uncle_david/article/details/78713551 对于搭建好的mongodb副本集加分片集群,为了安全,启动安全认证,使用 ...

  9. 玩转Django2.0---Django笔记建站基础九(一)(Auth认证系统)

    第九章 Auth认证系统 Django除了有强大的Admin管理系统之外,还提供了完善的用户管理系统.整个用户管理系统可分为三大部分:用户信息.用户权限和用户组,在数据库中分别对应数据表auth_us ...

随机推荐

  1. 数据库——SQL-SERVER练习(4) 建表及数据完整性

    1. 输入下图的语句, 建立学生表STU. CREATE TABLE STU ( SNO NUMERIC() PRIMARY KEY, SNANE CHAR() NOT NULL, SSEX CHAR ...

  2. 调试接口你还在用postman吗

    作者 | 陈凯玲 来源 | my.oschina.net/keking/blog/3104972 接口调试是每个软件开发从业者必不可少的一项技能,一个项目的的完成,可能接口测试调试的时间比真正开发写代 ...

  3. make 命令与 Makefile

    make 是一个工具程序,通过读取 Makefile 文件,实现自动化软件构建.虽然现代软件开发中,集成开发环境已经取代了 make,但在 Unix 环境中,make 仍然被广泛用来协助软件开发.ma ...

  4. cl_demo_output=>display 介绍

    Methods of CL_DEMO_OUTPUT PS:自己测试是display后的内表不能带表头. 类CL_DEMO_OUTPUT 在示例程序中创造了很多简单的数据输出的方法而不需要经典的list ...

  5. C# download big file

    I had validated this.To download SSMS which is more than 500M+ static void Main(string[] args) { str ...

  6. WPF——如何为项目设置全局样式。

    在项目中,需要为所有的Button.TextBox设置一个默认的全局样式,一个个的为多个控件设置相同的样式显然是不明智的.在WPF中可以通过资源设置全局样式,主要有俩种方法: 1.第一种就是先写好按钮 ...

  7. 反射DataTable转实体类

    using System; using System.Collections.Generic; using System.Data; using System.Reflection; namespac ...

  8. vue项目中使用sass

    1 安装sass npm install --save-loader npm install --save-dev node-sass 2 安装依赖 cnpm install stylus-loade ...

  9. IDEA设置默认WorkingDirectory

  10. idea中git标签(tag)的创建与使用

    1.什么是标签 通常,发布一个版本时,会在版本库中打一个标签(tag),这样,就唯一确定了打标签时刻的版本.将来无论什么时候,取某个标签的版本,就是把那个打标签的时刻的历史版本取出来. 所以,标签也是 ...