一、概述

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. 公益:开放一台Nacos服务端给各位Spring Cloud爱好者

    之前开放过一台公益Eureka Server给大家,以方便大家在阅读我博客中教程时候做实验.由于目前在连载Spring Cloud Alibaba,所以对应的也部署了一台Nacos,并且也开放出来,给 ...

  2. Ajax的快速入门

    1.什么是ajax ajax是技术名词的缩写: Asynchronous:异步: JavaScript:JavaScript语言: And:和.与: XML:数据传输格式 ajax是客户端通过HTTP ...

  3. android studio 出现找不到R文件的错误

    百度知道: 检查是否编译了项目.Android studio有时候没有编译就会报出没有R文件的错误. 检查带代码中包名是否正确.有时候从其他地方复制代码过来时连带了包名,也会报出R文件找不到. 检查布 ...

  4. idea使用心得

    简单的概括如下: IntelliJ系中的 Project  相当于Eclipse系中的  Workspace : IntelliJ系中的 Module  相当于Eclipse系中的  Project  ...

  5. vue-cli3和element做一个简单的登陆页面

    1.先用vue-cli3创建一个项目 2.安装element模块 全局安装 npm i element-ui -S 3在main.js引入模块 import ElementUI from 'eleme ...

  6. vue快速复习手册

    1.基本使用 <!DOCTYPE html> <head> <meta charset="UTF-8"> <title>Vue的基本 ...

  7. [转]C#操作Outlook

    本文转自:https://blog.csdn.net/yanlovehan/article/details/8500449 //引用Microsoft.Office.Interop.Outlook.d ...

  8. Android O的通知渠道适配

     在 Android O 以后,Google引入了通知通道的概念,如果目标API大于 Android O ,不直指定通知渠道是不能发送通知的. 这里放一个我写好的通知方法,大家可以适当的改改再用,*当 ...

  9. IDEA设置默认WorkingDirectory

  10. 【原创】CentOS 7 安装解压版mysql5.7

    1.将mysql压缩包解压至 /usr/local 文件夹下,将其改名为mysql #解压 tar -zxf mysql-5.7.27-el7-x86_64.tar.gz -C /usr/local/ ...