当前位置:网站首页>etcd集群权限管理和账号密码使用
etcd集群权限管理和账号密码使用
2022-07-03 13:46:00 【开发运维玄德公】
文章目录
1. 操作实例
1.1 环境说明
| 节点 | IP |
|---|---|
| etcd1 | 10.10.239.31:1379 |
| etcd2 | 10.10.239.31:2379 |
| etcd3 | 10.10.239.31:3379 |
1.2 创建root用户
root用户自带所有权限,因此只需创建该用户,开启认证即有所有权限。
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 user add root
- 输出如下
Password of root:
Type password of root again for confirmation:
User root created
交互需要输入用户密码
1.3 开启身份验证
- 开启身份验证
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 auth enable
- 测试:使用用户操作
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' put name "guanyu"
OK
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' get name
name
guanyu
- 测试:不使用用户密码操作报错
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl get name
{
"level":"warn","ts":"2022-07-02T08:11:34.599Z","logger":"etcd-client","caller":"v3/retry_interceptor.go:62","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0xc00014c000/127.0.0.1:2379","attempt":0,"error":"rpc error: code = InvalidArgument desc = etcdserver: user name is empty"}
Error: etcdserver: user name is empty
- 如果你决定对外公布root用户,那么到这里就可以了
- 如果要隐藏高权限的root用户,而公布普通用户,那继续往下操作
1.4 普通用户管理
1.4.1 创建普通用户
- 创建读用户
因为之前已经启用了密码访问,所以这里要加上用户和密码。没有启用的前当然不用加。
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 user add myRead
- 创建写用户
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 user add myWrite
- 创建读写用户
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 user list
- 查看用户
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 user add myReadWrite
输出:
myRead
myReadWrite
myWrite
root
1.4.2 创建角色
- 创建读角色
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 role add roleRead
- 创建写角色
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 role add roleWrite
- 创建读写角色
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 role add roleReadWrite
- 查看角色
I have no name!@75cdaac66149:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 role list
结果
roleRead
roleReadWrite
roleWrite
root
1.4.3 给角色赋权
- 读角色赋读权限
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 role grant-permission roleRead read /xishu/*
- 写角色赋写权限
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 role grant-permission roleWrite write /xishu/*
- 读写角色赋读写权限
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 role grant-permission roleReadWrite readwrite /xishu/*
- 查看角色权限
I have no name!@75cdaac66149:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 role get roleReadWrite
结果显示
Role roleReadWrite
KV Read:
/xishu/*
KV Write:
/xishu/*
1.4.4 给用户绑定角色
- 读用户绑定读角色
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 user grant-role myRead roleRead
- 写用户绑定写角色
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 user grant-role myWrite roleWrite
- 读角用户绑定读写角色
I have no name!@555187fb758c:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 user grant-role myReadWrite roleReadWrite
- 查看结果
I have no name!@75cdaac66149:/opt/bitnami/etcd$ etcdctl --user='root' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 user get myReadWrite
输出
User: myReadWrite
Roles: roleReadWrite
1.1.5 测试
- 用写账号写两条数据
I have no name!@75cdaac66149:/opt/bitnami/etcd$ etcdctl --user='myWrite' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 put /xishu/name "liubei"
OK
I have no name!@75cdaac66149:/opt/bitnami/etcd$ etcdctl --user='myWrite' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 put /xishu/age "28"
OK
- 用读账号读出来
I have no name!@75cdaac66149:/opt/bitnami/etcd$ etcdctl --user='myRead' --password='[email protected]' --endpoints http://10.10.239.31:1379,http://10.10.239.31:2379,http://10.10.239.31:3379 get /xishu/age
/xishu/age
28
2. 权限常用命令
2.1 用户管理
创建用户
etcdctl user add 用户名
删除用户
etcdctl user del 用户名
修改密码
etcdctl user passwd 用户名
查看所有用户
etcdctl user list
查看指定用户及绑定角色
etcdctl user get 用户名
2.2 角色
增加角色
etcdctl role add 角色名
给角色赋权
etcdctl grant-permission 角色名 [read|write|readwrite] 范围
范围如:
/xishu/*,/liubei
回收角色赋权
etcdctl role revoke-permission 角色名 被回收范围
删除角色
etcdctl role del 角色名
查询角色列表
etcdctl role list
查询指定角色的权限
etcdctl role get 角色名
2.3 用户&角色
用户绑定角色
etcdctl user grant-role 用户名 角色名
回收用户绑定权限
etcdctl user revoke-role 用户名 角色名
2.4 权限使用
etcdctl --user='用户名' --password='密码' ……
边栏推荐
- Vite project commissioning
- Redis: commandes d'action pour les données de type chaîne
- Exercise 10-3 recursive implementation of exponential functions
- 1px problem of mobile terminal
- Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
- 好看、好用、强大的手写笔记软件综合评测:Notability、GoodNotes、MarginNote、随手写、Notes Writers、CollaNote、CollaNote、Prodrafts、Noteshelf、FlowUs、OneNote、苹果备忘录
- Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
- Redis: operation command of string type data
- 泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
- MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)
猜你喜欢

Redis:Redis的数据结构、key的操作命令

How to use lxml to judge whether the website announcement is updated

信创产业现状、分析与预测

Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)"/>MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)

QT learning 24 layout manager (III)
[email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂"/>金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂

Understanding of closures

必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿

Comprehensive case of MySQL data addition, deletion, modification and query
随机推荐
Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:
金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
JS Part III
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
RocksDB LRUCache
Uniapp skills - scrolling components -1
6-9 statistics of single digits (15 points)
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
玖逸云黑免费无加密版本源码
Exercise 8-2 calculate the sum and difference of two numbers
PCB中常用快捷键
MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)
Leetcode (4) -- find the median of two positively ordered arrays
Why don't I have a rookie medal
Solution to failure or slow downloading of electron when electron uses electron builder to package
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
How to promote the progress of project collaboration | community essay solicitation
Exercise 7-6 count capital consonants
JS shift operators (< <,> > and > > >)
Too many files with unapproved license