zoukankan      html  css  js  c++  java
  • etcd 开启auth认证

    一、概述

    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

  • 相关阅读:
    如何禁用Xcode7下iOS9 App传输安全,并修复无法连接服务器错误
    iOS单例清除
    Git忽略规则及.gitignore规则不生效的解决办法
    javascript 在ie8中报“缺少标识符、字符串或数字“问题再现:
    树莓派 远程桌面 设置显示中文
    在IIS Express中调试时无法读取配置文件 错误
    Win7 下IIS(7.5)发布 ASP.NET MVC
    .Net中使用com组件后发生System.ArithmeticException异常的解决办法(Message=算术运算中发生溢出或下溢。)
    CodeSimth
    windows 开机启动 CassiniDev(IIS替代软件)
  • 原文地址:https://www.cnblogs.com/cuishuai/p/12024841.html
Copyright © 2011-2022 走看看