tokenpocketapp下载苹果|vault
私密信息管理工具 Vault 快速入门 - 知乎
私密信息管理工具 Vault 快速入门 - 知乎切换模式写文章登录/注册私密信息管理工具 Vault 快速入门INFINI Labs已认证账号什么是 VaultVault 是一个基于身份的秘密和加密管理系统。秘密是您想要严格控制访问的任何内容,例如 API 加密密钥、密码和证书。 Vault 提供由身份验证和授权方法控制的加密服务。使用 Vault 的 UI、CLI 或 HTTP API,可以安全地存储和管理、严格控制(限制)和审核对机密和其他敏感数据的访问。为什么需要 Vault执行密码轮换策略很痛苦掌握机密的员工离职后可能泄密或是恶意报复开发者不小心把机密信息随着代码上传到公网的源码仓库造成泄密管理多个系统的机密非常麻烦需要将机密信息安全地加密后存储,但又不想将密钥暴露给应用程序,以防止应用程序被入侵后连带密钥一起泄漏Vault 架构图Vault 只暴漏了存储后端(Storage Backend) 和 API,其他部分都被保护起来了。Vault 并不信任后端存储,存放的都是密文。安装此处以 Mac 为例,其他平台参考官方文档Vault 安装向导❯ brew tap hashicorp/tap
❯ brew install hashicorp/tap/vault
启动 Vault(Dev 模式)❯ vault server -dev
WARNING! dev mode is enabled! In this mode, Vault runs entirely in-memory
and starts unsealed with a single unseal key. The root token is already
authenticated to the CLI, so you can immediately begin using Vault.
You may need to set the following environment variables:
$ export VAULT_ADDR='http://127.0.0.1:8200'
The unseal key and root token are displayed below in case you want to
seal/unseal the Vault or re-authenticate.
Unseal Key: QNqS6xZOnJKsbcz60PThJE2O070F2+9b7LLrGGgI7os=
Root Token: hvs.IKbh5pTGI0Qn08G5QNJb4jPY
Development mode should NOT be used in production installations!
查看服务状态❯ vault status
Key Value
--- -----
Seal Type shamir
Initialized true
Sealed false
Total Shares 1
Threshold 1
Version 1.12.1
Build Date 2022-10-27T12:32:05Z
Storage Type inmem
Cluster Name vault-cluster-c5c1f8a4
Cluster ID 60514532-959b-9540-ea21-5d9c968a21ba
HA Enabled false
写入第一个密码❯ vault write kv/infini value=infinilabs
Success! Data written to: kv/infini
如果报这个错误:vault write kv/infini value=infinilabsError writing data to kv/cheng: Error making API request.URL: PUT http://127.0.0.1:8200/v1/kv/chengCode: 404. Errors:no handler for route 'kv/cheng'是因为 kv 存储没有启动(不同版本默认初始设置不同),执行:❯ vault secrets enable kv
读取一条数据❯ vault read kv/infini
Key Value
--- -----
refresh_interval 768h
value labs
使用 Consul 作为数据存储的 BackendVault 自身不存储数据,需要提供存储后台。 支持多种后台。❯ brew tap hashicorp/tap
❯ brew install hashicorp/tap/consul
启动 Consul❯ consul agent -dev
==> Starting Consul agent...
Version: '1.14.1'
Build Date: '2022-11-21 16:56:07 +0000 UTC'
Node ID: '6d9bcfc4-60cf-5d9b-c4fa-764127a94af6'
Node name: 'ChengKai-MacBook.local'
Datacenter: 'dc1' (Segment: '
Server: true (Bootstrap: false)
Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, gRPC: 8502, gRPC-TLS: 8503, DNS: 8600)
Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)
Gossip Encryption: false
Auto-Encrypt-TLS: false
HTTPS TLS: Verify Incoming: false, Verify Outgoing: false, Min Version: TLSv1_2
gRPC TLS: Verify Incoming: false, Min Version: TLSv1_2
Internal RPC TLS: Verify Incoming: false, Verify Outgoing: false (Verify Hostname: false), Min Version: TLSv1_2
==> Log data will now stream in as it occurs:
2022-11-30T16:34:52.604+0800 [WARN] agent: Node name "ChengKai-MacBook.local" will not be discoverable via DNS due to invalid characters. Valid characters include all alpha-numerics and dashes.
2022-11-30T16:34:52.609+0800 [WARN] agent.auto_config: Node name "ChengKai-MacBook.local" will not be discoverable via DNS due to invalid characters. Valid characters include all alpha-numerics and dashes.
2022-11-30T16:34:52.613+0800 [INFO] agent.server.raft: initial configuration: index=1 servers="[{Suffrage:Voter ID:6d9bcfc4-60cf-5d9b-c4fa-764127a94af6 Address:127.0.0.1:8300}]"
2022-11-30T16:34:52.614+0800 [INFO] agent.server.raft: entering follower state: follower="Node at 127.0.0.1:8300 [Follower]" leader-address= leader-id=
启动 Vault(生产模式)创建配置文件,使用刚刚启动的 Consul 作为存储后台。注意: 这种方式启动,为生产模式,需要手动配置和管理秘钥。storage "consul"{
address = "127.0.0.1:8500"
path = "vault/"
}
listener "tcp"{
address = "127.0.0.1:8200"
tls_disable = 1
}执行命令,启动❯ vault server -config=config.hcl
WARNING! mlock is not supported on this system! An mlockall(2)-like syscall to
prevent memory from being swapped to disk is not supported on this system. For
better security, only run Vault on systems where this call is supported. If
you are running Vault in a Docker container, provide the IPC_LOCK cap to the
container.
==> Vault server configuration:
Api Address: http://127.0.0.1:8200
Cgo: disabled
Cluster Address: https://127.0.0.1:8201
Go Version: go1.19.2
Listener 1: tcp (addr: "127.0.0.1:8200", cluster address: "127.0.0.1:8201", max_request_duration: "1m30s", max_request_size: "33554432", tls: "disabled")
Log Level: info
Mlock: supported: false, enabled: false
Recovery Mode: false
Storage: consul (HA available)
Version: Vault v1.12.1, built 2022-10-27T12:32:05Z
Version Sha: e34f8a14fb7a88af4640b09f3ddbb5646b946d9c
==> Vault server started! Log data will stream in below:
2022-11-30T16:42:59.995+0800 [INFO] proxy environment: http_proxy="" https_proxy="" no_proxy=""
2022-11-30T16:43:00.006+0800 [WARN] no `api_addr` value specified in config or in VAULT_API_ADDR; falling back to detection if possible, but this value should be manually set
注意: 此时虽然服务启动了,但是 Vault 处于封印状态(sealed), 不可用。此时我们执行操作,会看到如下提示:❯ vault read kv/cheng
Error reading kv/cheng: Error making API request.
URL: GET http://127.0.0.1:8200/v1/kv/cheng
Code: 503. Errors:
* Vault is sealed
上面 Dev 模式启动的 Vault 实际上帮助我们自动地把创建主密钥、解封的步骤都完成了。生产模式,则需要手动配置后续步骤。补充点小知识Vault 保存在 Backend 中的数据都是加密的Vault 密钥称为 Master Key 主密钥,Vault 默认使用 Shamir 算法,把主密钥切分成 M 份,管理员必须至少提供其中的 N 份才能还原出主密钥(这里的 M 和 N 都是可配置的,M>=N)理想状态下,我们必须把这 M 份密钥分配给公司内 M 个不同的人,只有在获取其中 N 个人的授权后,Vault 才可以成功解密主密钥。Vault 初始化(生产模式)注意看,接下来的步骤,会生成 5 个秘钥,一个 Root 用户的 Token。真实场景下,这 5 个秘钥会分配给 5 个不同的人员管理。 至少正确输入 3 个秘钥,才能解封 Vault。热知识: Vault 每次启动/重启,都会进入封印状态,未解封时,几乎无法执行任何操作。> vault operator init
Unseal Key 1: IDcHr5kT7hhgYKiDxF6Qlp2g11UVXNu+f5VX51+3jpeD
Unseal Key 2: dfjqn++KcqLDIDnBcE8B0fIvicI7T9TQCxBSI7b1oE12
Unseal Key 3: DaFtgnYsm0rTQcPpLTPaDTNW338BHhyhezct+ySTT45L
Unseal Key 4: Z1vmlLm/KBydeLrmVf9ELqlJoaUgwzNvzx6ddXttc4Nk
Unseal Key 5: x2lIwJiCz3lNqzBPzkryrnatfZT9mahj3yfW4qxT3eMZ
Initial Root Token: s.o7NjzR6qXEvJEwPYpmVFOt4P
Vault initialized with 5 key shares and a key threshold of 3. Please securely
distribute the key shares printed above. When the Vault is re-sealed,
restarted, or stopped, you must supply at least 3 of these keys to unseal it
before it can start servicing requests.
Vault does not store the generated master key. Without at least 3 keys to
reconstruct the master key, Vault will remain permanently sealed!
It is possible to generate new unseal keys, provided you have a quorum of
existing unseal keys shares. See "vault operator rekey" for more information.Vault 默认访问 https 的地址,所以如果执行初始化报如下错误:Error authenticating: error looking up token: Get "https://127.0.0.1:8200/v1/auth/token/lookup-self": http: server gave HTTP response to HTTPS client设置一下 Vault 地址即可,执行:export VAULT_ADDR='http://127.0.0.1:8200'查看 Vault 状态此时 Vault 处于封印状态(Sealed 为 true)❯ vault status
Key Value
--- -----
Seal Type shamir
Initialized true
Sealed true
Total Shares 5
Threshold 3
Unseal Progress 0/3
Unseal Nonce n/a
Version 1.9.2
Storage Type consul
HA Enabled true
解封 Vault使用需要 vault operator unseal 命令来执行解封。至少需要 3 个秘钥来解封。❯ vault operator unseal IDcHr5kT7hhgYKiDxF6Qlp2g11UVXNu+f5VX51+3jpeD
Key Value
--- -----
Seal Type shamir
Initialized true
Sealed true
Total Shares 5
Threshold 3
Unseal Progress 1/3
Unseal Nonce 9eeaaa92-d673-51d3-b993-d3affe68b5a3
Version 1.9.2
Storage Type consul
HA Enabled true
注意: 每次输入一个秘钥,会看到如上提示"Unseal Progress 1/3"。 但是,这里仅仅表示已经输入多少个秘钥,并不代表输入的秘钥都是正确的!!如何使用 Vault 保存秘密进入下一步之前,先来看看 Vault 提供了哪些措施,用来保护我们的秘密?秘钥的保护机制: 秘钥被拆分成 5 份,至少正确输入 3 个才能解封。策略控制(权限控制): 可以针对每个 Path 设置策略。有效期: Vault 生成的每个令牌(Token)都有有效期。开始前,我们先写入 2 条测试数据:❯ vault write kv/infini value=infinilabs
Success! Data written to: kv/infini
❯ vault write kv/ck value=chengkai
Success! Data written to: kv/ck
热知识:"kv/infini" 是一个 Path(路径), 可以简单理解为数据库中的一个表。并不是 kv 数据库 当中的 key。你可以试试这样存数据并读取:❯ vault write kv/infini ck=chengkai c=cheng k=kai
Success! Data written to: kv/infini
❯ vault read kv/infini
Key Value
--- -----
refresh_interval 768h
c cheng
ck chengkai
k kai
制定策略新建策略文件输入以下内容path "kv/infini" {
capabilities = ["read"]
}
解释: 以上策略,是指在 infini 这个路径(path)下,具有只读权限。创建策略先登录已经解封的 Vault(使用初始化生成的 root token 登录)❯ vault login s.o7NjzR6qXEvJEwPYpmVFOt4P
Success! You are now authenticated. The token information displayed below
is already stored in the token helper. You do NOT need to run "vault login"
again. Future Vault requests will automatically use this token.
Key Value
--- -----
token s.o7NjzR6qXEvJEwPYpmVFOt4P
token_accessor tKZyxkkFvrmhQeTsoDOogcoV
token_duration ∞
token_renewable false
token_policies ["root"]
identity_policies []
policies ["root"]
❯ vault policy write infini-readonly policy.hcl
Success! Uploaded policy: infini-readonly
"infini-readonly" 是策略的名称,这个可以自定义生成 Token 并指定策略生成对"kv/infini"具有只读权限的 Token, 执行:❯ vault token create -policy="infini-readonly"
Key Value
--- -----
token s.bHzsfREs9MGirYO8yZ2TbAzq
token_accessor nPuAQzNTn28vMMUKcDu0mN8g
token_duration 768h
token_renewable true
token_policies ["infini-readonly" "default"]
identity_policies []
policies ["infini-readonly" "default"]
此处生成了新的 Token: s.bHzsfREs9MGirYO8yZ2TbAzq, 有效期 768 小时(别拿计算器了,我算过了,32 天)使用新生成的 Token 登录(别找退出操作了,直接再执行 login 即可):❯ vault login s.bHzsfREs9MGirYO8yZ2TbAzq
Success! You are now authenticated. The token information displayed below
is already stored in the token helper. You do NOT need to run "vault login"
again. Future Vault requests will automatically use this token.
Key Value
--- -----
token s.bHzsfREs9MGirYO8yZ2TbAzq
token_accessor nPuAQzNTn28vMMUKcDu0mN8g
token_duration 767h56m19s
token_renewable true
token_policies ["infini-readonly" "default"]
identity_policies []
policies ["infini-readonly" "default"]
验证新生成的 Token尝试读 kv/infini 的秘密:❯ vault read kv/infini
Key Value
--- -----
refresh_interval 768h
value infinilabs
Wow!成功读取!试试写入操作❯ vault write kv/infini value=c1
Error writing data to kv/cheng: Error making API request.
URL: PUT http://127.0.0.1:8200/v1/kv/infini
Code: 403. Errors:
* 1 error occurred:
* permission denied
有个疑问,你说当前这个 Token,可以读取 kv/ck 的秘密吗?❯ vault read kv/ck
Error reading kv/ck: Error making API request.
URL: GET http://127.0.0.1:8200/v1/kv/ck
Code: 403. Errors:
* 1 error occurred:
* permission denied
啊欧! 不行~OK, 到这里了,简单的对 Vault 做了个入门。 Vault 的功能点还有很多,去看看下面的文档吧~~参考文档[1]: Vault 官方文档[2]: Vault 教程(中文)[3]: How To Securely Manage Secrets with HashiCorp Vault on Ubuntu 20.04发布于 2023-08-23 15:06・IP 属地湖南工具软件加密赞同 1添加评论分享喜欢收藏申请
私密信息管理利器 HashiCorp Vault——简介 - 掘金
私密信息管理利器 HashiCorp Vault——简介 - 掘金
首页 首页
沸点
课程
直播
活动
竞赛
商城
APP
插件 搜索历史
清空
创作者中心
写文章 发沸点 写笔记 写代码 草稿箱 创作灵感
查看更多
会员
登录
注册
私密信息管理利器 HashiCorp Vault——简介
shuhari
2018-02-08
5,849
最近,由于项目中需要使用保存和管理的加密配置,并且我相信自己发明加密方法并不是一个合理的选择,所以开始寻找相关的方案。经过选型,确定了 HashCorp Valut。
目前,在网络上除了官方文档之外,能找到的相关资料非常至少。这或许是因为 Vault 尚未得到大规模使用,不过也有可能是因为涉及到私密性的信息,所以不方便公开讲。不论原因为何,本文和后续的文章希望把使用 HashiCorp Vault 的经验和心得记录下来,为后来人提供一点方便。
关于 HashiCorp
HashiCorp 是一家专注于基础设施解决方案的公司,业务范围涵盖软件开发中的部署、运维、安全等方面。下图是该公司的主要产品线,其中大部分知名度不算高,但大名鼎鼎的 Vagrant 相信很多人都听说过。
什么是 HashiCorp Vault
HashiCorp Vault 的 Slogan 是 A Tool for Managing Secrets,这个口号很好的描述了该产品的定位。大多数软件项目都会不同程度的用到诸如 登录密码/Token/证书/API Key 等私密信息,这些信息用明码保存显然是很不安全的,如果不小心签入到版本控制系统,还会造成重大的安全问题(这方面的事故我们已经听到过很多次了)。
Vault 就是为了解决这一问题而创立的。它提供了这些功能:
集中管理各种私密信息;
为私密信息设置租期(Lease),到期后自动失效;
密钥的动态生成、注销和滚动更新;
动态创建无需保存的一次性登录密钥;
作为数据加密/解密接口;
完整的审计记录;
命令行 以及 RESTful API 访问接口;
此外,Vault 设计为灵活的可插拔架构,允许灵活的设置各种后端引擎和安全策略。例如:
可以用内置 Token、用户/密码、LDAP、Amazon IAM、Github 等作为认证授权机制;
可以使用内存/本地文件/Etcd/Consul/ZooKeeper/RDBMS/NoSQL/云平台等作为数据存储;
可以为数据库/SSH/Consul/AWS/Nomad/PKI/RabbitMQ 等多种平台生成和管理访问密钥;
可以与 Cousul、Chef、Ansible 等运维工具集成起来共同使用;
使用场景和比较
由于私密信息的管理是一个带有普遍性的需求,所以业界对该问题也已经有多种处理办法。这里简单描述 Vault 和其他私密管理方案的对比,以便你有一个更好的理解。
需要说明的是,这里的描述部分来自官方文档中的 Vault vs Other Software。官方的描述更加完整,而我按照自己的理解做了整理和简化。如果你英文比较好的话,我建议直接阅读原文。
运维工具(Chef,Puppet,Consul等) 由于经常需要记录各种连接信息,这些运维工具也有自己的加密机制,例如 Chef data bag/Puppet Hiera。如果重点在于运维,对安全性要求不是很高,那么使用这些工具来处理私密信息也是完全可行的。它们的问题在于安全性不够高,容易发生泄露问题,此外也缺乏像 Vault 那样完整的审核记录。另外,Vault 也能够和这些运维工具结合起来使用。
硬件安全模块(Hardware Security Model, HSM) 按照定义来说是基于硬件的,不过也有 Amazon CloudHSM 这样的服务形式。HSM 的安全等级是足够高的,不过它们通常价格昂贵、管理麻烦,基于硬件的形式对云平台通常不太友好,大多数中小企业一般不会考虑。如果你确实有 HSM 可用的话,那么用它来管理 Vault 的主密钥也是一个合理的选择,不过用 HSM 来管理所有私密信息通常是太过重量级了。
DropBox(及其他类似的网盘) 我们都明白:用这种方法来管理私密信息,在安全性的角度来讲肯定是不合格的,但由于使用方便,事实上还真有很多不太注重安全的用户走了这个路子。Vault 的作者当然是不鼓励这种做法的,并且希望 Vault 相比其他更加重量级的解决方案来说能够在使用上更加简便。
Amazon KMS(Key Management Service) 从名字上就能看出,KMS 注重的是密钥的管理,Vault 则更加灵活。KMS 和 Amazon 自身的云平台集成更佳,并且是一个纯粹的云端解决方案,而 Vault 既可以本地运行,也可以部署到云端(有官方的 Docker 镜像可用)。
Square Keywhiz 我们知道 Square 主要是做网络支付的公司,业务特点决定了他们对于安全也非常重视,Keywhize 就是他们开发的私密信息管理工具。我没有用过 Keywhiz,不好评价。不过从官方介绍来看,Keywhiz 和 Vault 的功能特性非常相似,基本可以互相取代。目前, Vault 似乎受关注度更高一些,未来就看哪一个项目发展的更好了。为了方便比较,我在下面做了一个 Vault 和 Keywhiz 的简单对比表,你可以按照自己的喜好来选择。
1Password 1Password 等工具也是部分用户喜欢的私密信息解决方案。尽管这是一个相当不错的密码管理工具,但它是存粹的客户端程序,管理密码基本靠人工,从专业的 DevOps 观点来说,这种方式是不合理的。此外,它也缺乏密钥生成和期限管理、审核记录等高级功能。
商业解决方案 某些存储平台,例如 SQL Server,提供了自己的列加密机制。如果你的项目大量依赖于这些平台、且迁移到其他平台的可能性很小,那么使用内置的机制也无可厚非。它的(潜在)问题是不开源、不透明,存在供应商锁定的风险。
自定义方案 有些用户和项目可能已经开发了自己的私密信息解决方案,通常是自己编写的代码。按照业界的普遍观点,自己编码处理加密问题是危险的,非安全专家编写的安全代码通常会有大量的潜在漏洞,而且这些漏洞通常比一般的业务 bug 更加难以发现和解决。总之,不要发明自己的密码方案。
项目
Vault
Keywhiz
厂商
HashiCorp
Square
模式
开源
开源
开发语言
Golang
Java
代码库
Github
Github
Forks
1206
148
Stars
8449
1867
术语
由于是一个安全工具,HashiCorp Vault 使用中会涉及到不少有一定专业性的术语,如果不理解这些术语的话,在使用该平台和阅读文章时会收到一定影响。以下列出该工具使用中将会用到的一些术语,你可以先粗略浏览一下,有个大概印象,不完全理解也没有关系,后面在使用过程中会结合具体用法详细讲述。
术语
中文
释义
Lease
租期
私密信息的有效期/过期时间
Seal/Unseal
密封/解封
对私密信息存储开启/关闭客户端访问的过程
Token
凭据
Vault 验证用户的默认机制
Path
路径
Vault 区分数据的保存位置
Secret Engine
加密引擎
支持不同渠道的加密方法
Auth Method
验证方法
验证登录用户信息
Policy
策略
实现用户授权机制
相关问题
Vault 是一个英文常用词。如果你把这个词直接放到搜索引擎里面去的话,可能会找到一大堆不相干的内容。所以你最好是搜索产品的全称:HashiCorp Vault。
系列文章
本文是该系列的第一篇,讲述 HashiCorp Vault 的总体概念和功能。接下来将介绍该工具的安装和使用。
私密信息管理利器 HashiCorp Vault——简介
私密信息管理利器 HashiCorp Vault——启动和读写
私密信息管理利器 HashiCorp Vault——加密引擎
私密信息管理利器 HashiCorp Vault——验证和授权
私密信息管理利器 HashiCorp Vault——部署
私密信息管理利器 HashiCorp Vault——REST API
shuhari
后端 @自由职业
35
文章
47k
阅读
27
粉丝 目录 收起
关于 HashiCorp
什么是 HashiCorp Vault
使用场景和比较
术语
相关问题
系列文章
友情链接:
杜月笙家谱关系图
沈先生的心头宝无弹窗
快穿女主小三心机绿茶pop文
ajax数据库javascript
redis集群三种方式cor
天医风水师的五个媳妇
GitHub - hashicorp/vault: A tool for secrets management, encryption as a service, and privileged access management
GitHub - hashicorp/vault: A tool for secrets management, encryption as a service, and privileged access management
Skip to content
Toggle navigation
Sign in
Product
Actions
Automate any workflow
Packages
Host and manage packages
Security
Find and fix vulnerabilities
Codespaces
Instant dev environments
Copilot
Write better code with AI
Code review
Manage code changes
Issues
Plan and track work
Discussions
Collaborate outside of code
Explore
All features
Documentation
GitHub Skills
Blog
Solutions
For
Enterprise
Teams
Startups
Education
By Solution
CI/CD & Automation
DevOps
DevSecOps
Resources
Learning Pathways
White papers, Ebooks, Webinars
Customer Stories
Partners
Open Source
GitHub Sponsors
Fund open source developers
The ReadME Project
GitHub community articles
Repositories
Topics
Trending
Collections
Pricing
Search or jump to...
Search code, repositories, users, issues, pull requests...
Search
Clear
Search syntax tips
Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
Sign up
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
hashicorp
/
vault
Public
Notifications
Fork
4k
Star
29.4k
A tool for secrets management, encryption as a service, and privileged access management
www.vaultproject.io/
License
View license
29.4k
stars
4k
forks
Branches
Tags
Activity
Star
Notifications
Code
Issues
994
Pull requests
343
Actions
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security
Insights
hashicorp/vault
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mainBranchesTagsGo to fileCodeFolders and filesNameNameLast commit messageLast commit dateLatest commit History19,197 Commits.github.github .hooks.hooks .release.release META.dMETA.d apiapi auditaudit builtinbuiltin changelogchangelog commandcommand dependencies/2-25-21dependencies/2-25-21 enosenos helperhelper httphttp internal/observability/eventinternal/observability/event internalsharedinternalshared limitslimits physicalphysical pluginsplugins scriptsscripts sdksdk serviceregistrationserviceregistration shamirshamir terraformterraform toolstools uiui vaultvault versionversion websitewebsite .copywrite.hcl.copywrite.hcl .gitattributes.gitattributes .gitignore.gitignore .go-version.go-version .yamllint.yamllint CHANGELOG-pre-v1.10.mdCHANGELOG-pre-v1.10.md CHANGELOG-v0.mdCHANGELOG-v0.md CHANGELOG.mdCHANGELOG.md CODEOWNERSCODEOWNERS CONTRIBUTING.mdCONTRIBUTING.md DockerfileDockerfile HCPV_badge.pngHCPV_badge.png LICENSELICENSE MakefileMakefile README.mdREADME.md buf.gen.yamlbuf.gen.yaml buf.lockbuf.lock buf.yamlbuf.yaml go.modgo.mod go.sumgo.sum main.gomain.go main_test.gomain_test.go make.batmake.bat scan.hclscan.hcl View all filesRepository files navigationREADMECode of conductLicenseSecurityVault
Please note: We take Vault's security and our users' trust very seriously. If you believe you have found a security issue in Vault, please responsibly disclose by contacting us at security@hashicorp.com.
Website: https://www.vaultproject.io
Announcement list: Google Groups
Discussion forum: Discuss
Documentation: https://developer.hashicorp.com/vault/docs
Tutorials: https://developer.hashicorp.com/vault/tutorials
Certification Exam: https://developer.hashicorp.com/certifications/security-automation
Vault is a tool for securely accessing secrets. A secret is anything that you want to tightly control access to, such as API keys, passwords, certificates, and more. Vault provides a unified interface to any secret, while providing tight access control and recording a detailed audit log.
A modern system requires access to a multitude of secrets: database credentials, API keys for external services, credentials for service-oriented architecture communication, etc. Understanding who is accessing what secrets is already very difficult and platform-specific. Adding on key rolling, secure storage, and detailed audit logs is almost impossible without a custom solution. This is where Vault steps in.
The key features of Vault are:
Secure Secret Storage: Arbitrary key/value secrets can be stored
in Vault. Vault encrypts these secrets prior to writing them to persistent
storage, so gaining access to the raw storage isn't enough to access
your secrets. Vault can write to disk, Consul,
and more.
Dynamic Secrets: Vault can generate secrets on-demand for some
systems, such as AWS or SQL databases. For example, when an application
needs to access an S3 bucket, it asks Vault for credentials, and Vault
will generate an AWS keypair with valid permissions on demand. After
creating these dynamic secrets, Vault will also automatically revoke them
after the lease is up.
Data Encryption: Vault can encrypt and decrypt data without storing
it. This allows security teams to define encryption parameters and
developers to store encrypted data in a location such as a SQL database without
having to design their own encryption methods.
Leasing and Renewal: All secrets in Vault have a lease associated
with them. At the end of the lease, Vault will automatically revoke that
secret. Clients are able to renew leases via built-in renew APIs.
Revocation: Vault has built-in support for secret revocation. Vault
can revoke not only single secrets, but a tree of secrets, for example,
all secrets read by a specific user, or all secrets of a particular type.
Revocation assists in key rolling as well as locking down systems in the
case of an intrusion.
Documentation, Getting Started, and Certification Exams
Documentation is available on the Vault website.
If you're new to Vault and want to get started with security automation, please
check out our Getting Started guides
on HashiCorp's learning platform. There are also additional guides
to continue your learning.
For examples of how to interact with Vault from inside your application in different programming languages, see the vault-examples repo. An out-of-the-box sample application is also available.
Show off your Vault knowledge by passing a certification exam. Visit the
certification page
for information about exams and find study materials
on HashiCorp's learning platform.
Developing Vault
If you wish to work on Vault itself or any of its built-in systems, you'll
first need Go installed on your machine.
For local dev first make sure Go is properly installed, including setting up a
GOPATH. Ensure that $GOPATH/bin is in
your path as some distributions bundle the old version of build tools. Next, clone this
repository. Vault uses Go Modules,
so it is recommended that you clone the repository outside of the GOPATH.
You can then download any required build tools by bootstrapping your environment:
$ make bootstrap
...
To compile a development version of Vault, run make or make dev. This will
put the Vault binary in the bin and $GOPATH/bin folders:
$ make dev
...
$ bin/vault
...
To compile a development version of Vault with the UI, run make static-dist dev-ui. This will
put the Vault binary in the bin and $GOPATH/bin folders:
$ make static-dist dev-ui
...
$ bin/vault
...
To run tests, type make test. Note: this requires Docker to be installed. If
this exits with exit status 0, then everything is working!
$ make test
...
If you're developing a specific package, you can run tests for just that
package by specifying the TEST variable. For example below, only
vault package tests will be run.
$ make test TEST=./vault
...
Importing Vault
This repository publishes two libraries that may be imported by other projects:
github.com/hashicorp/vault/api and github.com/hashicorp/vault/sdk.
Note that this repository also contains Vault (the product), and as with most Go
projects, Vault uses Go modules to manage its dependencies. The mechanism to do
that is the go.mod file. As it happens, the presence of that file
also makes it theoretically possible to import Vault as a dependency into other
projects. Some other projects have made a practice of doing so in order to take
advantage of testing tooling that was developed for testing Vault itself. This
is not, and has never been, a supported way to use the Vault project. We aren't
likely to fix bugs relating to failure to import github.com/hashicorp/vault
into your project.
See also the section "Docker-based tests" below.
Acceptance Tests
Vault has comprehensive acceptance tests
covering most of the features of the secret and auth methods.
If you're working on a feature of a secret or auth method and want to
verify it is functioning (and also hasn't broken anything else), we recommend
running the acceptance tests.
Warning: The acceptance tests create/destroy/modify real resources, which
may incur real costs in some cases. In the presence of a bug, it is technically
possible that broken backends could leave dangling data behind. Therefore,
please run the acceptance tests at your own risk. At the very least,
we recommend running them in their own private account for whatever backend
you're testing.
To run the acceptance tests, invoke make testacc:
$ make testacc TEST=./builtin/logical/consul
...
The TEST variable is required, and you should specify the folder where the
backend is. The TESTARGS variable is recommended to filter down to a specific
resource to test, since testing all of them at once can sometimes take a very
long time.
Acceptance tests typically require other environment variables to be set for
things such as access keys. The test itself should error early and tell
you what to set, so it is not documented here.
For more information on Vault Enterprise features, visit the Vault Enterprise site.
Docker-based Tests
We have created an experimental new testing mechanism inspired by NewTestCluster.
An example of how to use it:
import (
"testing"
"github.com/hashicorp/vault/sdk/helper/testcluster/docker"
)
func Test_Something_With_Docker(t *testing.T) {
opts := &docker.DockerClusterOptions{
ImageRepo: "hashicorp/vault", // or "hashicorp/vault-enterprise"
ImageTag: "latest",
}
cluster := docker.NewTestDockerCluster(t, opts)
defer cluster.Cleanup()
client := cluster.Nodes()[0].APIClient()
_, err := client.Logical().Read("sys/storage/raft/configuration")
if err != nil {
t.Fatal(err)
}
}
Or for Enterprise:
import (
"testing"
"github.com/hashicorp/vault/sdk/helper/testcluster/docker"
)
func Test_Something_With_Docker(t *testing.T) {
opts := &docker.DockerClusterOptions{
ImageRepo: "hashicorp/vault-enterprise",
ImageTag: "latest",
VaultLicense: licenseString, // not a path, the actual license bytes
}
cluster := docker.NewTestDockerCluster(t, opts)
defer cluster.Cleanup()
}
Here is a more realistic example of how we use it in practice. DefaultOptions uses
hashicorp/vault:latest as the repo and tag, but it also looks at the environment
variable VAULT_BINARY. If populated, it will copy the local file referenced by
VAULT_BINARY into the container. This is useful when testing local changes.
Instead of setting the VaultLicense option, you can set the VAULT_LICENSE_CI environment
variable, which is better than committing a license to version control.
Optionally you can set COMMIT_SHA, which will be appended to the image name we
build as a debugging convenience.
func Test_Custom_Build_With_Docker(t *testing.T) {
opts := docker.DefaultOptions(t)
cluster := docker.NewTestDockerCluster(t, opts)
defer cluster.Cleanup()
}
There are a variety of helpers in the github.com/hashicorp/vault/sdk/helper/testcluster
package, e.g. these tests below will create a pair of 3-node clusters and link them using
PR or DR replication respectively, and fail if the replication state doesn't become healthy
before the passed context expires.
Again, as written, these depend on having a Vault Enterprise binary locally and the env
var VAULT_BINARY set to point to it, as well as having VAULT_LICENSE_CI set.
func TestStandardPerfReplication_Docker(t *testing.T) {
opts := docker.DefaultOptions(t)
r, err := docker.NewReplicationSetDocker(t, opts)
if err != nil {
t.Fatal(err)
}
defer r.Cleanup()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
err = r.StandardPerfReplication(ctx)
if err != nil {
t.Fatal(err)
}
}
func TestStandardDRReplication_Docker(t *testing.T) {
opts := docker.DefaultOptions(t)
r, err := docker.NewReplicationSetDocker(t, opts)
if err != nil {
t.Fatal(err)
}
defer r.Cleanup()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
err = r.StandardDRReplication(ctx)
if err != nil {
t.Fatal(err)
}
}
Finally, here's an example of running an existing OSS docker test with a custom binary:
$ GOOS=linux make dev
$ VAULT_BINARY=$(pwd)/bin/vault go test -run 'TestRaft_Configuration_Docker' ./vault/external_tests/raft/raft_binary
ok github.com/hashicorp/vault/vault/external_tests/raft/raft_binary 20.960s
About
A tool for secrets management, encryption as a service, and privileged access management
www.vaultproject.io/
Topics
go
vault
secrets
Resources
Readme
License
View license
Code of conduct
Code of conduct
Security policy
Security policy
Activity
Custom properties
Stars
29.4k
stars
Watchers
825
watching
Forks
4k
forks
Report repository
Releases
130
v1.15.6
Latest
Feb 29, 2024
+ 129 releases
Packages
0
No packages published
Used by 1.8k
+ 1,827
Contributors
1,293
+ 1,279 contributors
Languages
Go
58.9%
MDX
17.8%
JavaScript
15.8%
Handlebars
4.1%
HCL
1.6%
TypeScript
0.8%
Other
1.0%
Footer
© 2024 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Docs
Contact
Manage cookies
Do not share my personal information
You can’t perform that action at this time.
Vault by HashiCorp
t by HashiCorpOverviewUse CasesAutomated PKI infrastructureData encryption and tokenizationDatabase credential rotationDynamic secretsIdentity-based accessKey managementKubernetes SecretsSecrets managementEnterpriseTutorialsDocsAPICommunityGitHubDownloadTry HCP VaultManage secrets and protect sensitive data with VaultSecure, store, and tightly control access to tokens, passwords, certificates, and encryption keys for protecting secrets and other sensitive data using a UI, CLI, or HTTP API.Try HCP VaultDownload VaultIdentity-based securityVault brokers and deeply integrates with trusted identities to automate access to secrets, data, and systems.Application and machine identitySecure applications and systems with machine identity and automate credential issuance, rotation, and more. Enable attestation of application and workload identity, using Vault as the trusted authority.User identity with VaultLeverage trusted identity platforms you use everyday to secure, store, and access credentials and resources.Play videoHow Vault worksVault tightly controls access to secrets and encryption keys by authenticating against trusted sources of identity such as Active Directory, LDAP, Kubernetes, CloudFoundry, and cloud platforms.Armon DadgarCo-founder & CTOCommon use cases for VaultSecrets managementCentrally store, access, and deploy secrets across applications, systems, and infrastructure.Dynamic secretsA dynamic secret is generated on demand and is unique to a client, instead of a static secret, which is defined ahead of time and shared.Kubernetes secretsInstall Vault using a Helm chart and then leverage Vault and Kubernetes to securely inject secrets into your application stack.Database credential rotationAutomatically rotate database passwords with Vault's database secrets engine.Automated PKI infrastructureUse Vault to quickly create X.509 certificates on demand and reduce the manual overhead.Identity-based accessAuthenticate and access different clouds, systems, and endpoints using trusted identities.Data encryption and tokenizationKeep application data secure with one centralized workflow for data that resides in untrusted or semi-trusted systems outside of Vault.Key managementUse a standardized workflow for distribution and lifecycle management across KMS providers.Vault in practiceThe best way to understand what Vault can enable for your projects is to see it in action.TutorialSecrets storageSecurely store and manage access to secrets and systems based on trusted sources of application and user identity.TutorialDynamic secretsGenerate time-based access credentials dynamically based on policies and revoke access when lease expires.TutorialAutomate credential rotationReduce risk of secret exposure by automating how long secrets live and rotating secrets across your entire fleet.DocumentationEncryption as a serviceSecure application data with one centralized workflow that resides in untrusted or semi-trusted systems outside of Vault.TutorialAPI-driven encryptionVault provides rich APIs to protect data, while using the state of the art in cryptography.TutorialEncryption key rollingAutomatically update and rotate encryption keys without code changes, configuration updates, or re-deploys.Customer storiesAn inside look at powerful solutions from some of the world’s most innovative companies.GitHub: Cracking the codeUbisoft: Game timeVodafone: Unlocking possibilitiesSBB: Modern secrets management for a modern railway operatorQ2: Multi-cloud win using infrastructure as codeYahoo! JAPAN: Secrets at scale for Japan’s most visited websiteGet HashiCorp CertifiedLevel up your concepts, skills, and use cases associated with HashiCorp Vault.Prepare and get certifiedLearn more about Vault Ops ProNext stepsHCP Vault simplifies cloud security automation on fully managed infrastructure. Get started for free, and pay only for what you use. CommunitySelf-managed | Always freeDownloadCloudManaged VaultCompare plansEnterpriseSelf-managed custom deploymentsLearn moreDocsAPITutorialsCommunityPrivacySecurityPress KitConsent ManaVault从入门到精通系列之一:深入了解安全工具Vault、Vault根令牌和解封密钥,详细整理部署Vault的详细步骤_如何配置一个vaultmount实例-CSDN博客
>Vault从入门到精通系列之一:深入了解安全工具Vault、Vault根令牌和解封密钥,详细整理部署Vault的详细步骤_如何配置一个vaultmount实例-CSDN博客
Vault从入门到精通系列之一:深入了解安全工具Vault、Vault根令牌和解封密钥,详细整理部署Vault的详细步骤
最新推荐文章于 2023-12-22 14:16:05 发布
最笨的羊羊
最新推荐文章于 2023-12-22 14:16:05 发布
阅读量2k
收藏
8
点赞数
1
分类专栏:
日常分享专栏
文章标签:
Vault
Vault根令牌和解封密钥
部署Vault的详细步骤
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/zhengzaifeidelushang/article/details/131283430
版权
日常分享专栏
专栏收录该内容
421 篇文章
62 订阅
订阅专栏
Vault从入门到精通系列之一:深入了解安全工具Vault、Vault根令牌和解封密钥,详细整理部署Vault的详细步骤
一、深入了解安全工具Vault二、Vault根令牌和解封密钥的含义和作用三、centos7上部署和启动Vault的流程四、vault下载地址五、安装vault六、启动Vault七、总结和延伸
一、深入了解安全工具Vault
Vault是一种开源工具,用于安全地存储、管理和控制访问各种机密信息,如密码、API令牌、安全配置和其他敏感数据。Vault使用强大的加密和安全管理技术来保护这些机密信息,并为应用程序和服务提供安全的访问控制机制。该工具支持各种云平台和技术堆栈,并提供多种API和CLI接口,使其易于集成和使用。Vault的主要特点包括中心化管理、角色分配和权限控制、审计和日志记录、动态秘钥持续更新等。这些功能使得Vault成为一款颇受开发者和企业信赖的安全工具。
二、Vault根令牌和解封密钥的含义和作用
Vault 中的根令牌和解封密钥是用于管理和保护 Vault 中加密数据的重要凭据。
根令牌是 Vault 中的最高权限凭据,拥有此令牌的用户可以在 Vault 中进行任何操作,包括创建和删除机密、管理策略、配置身份验证等。因此,根令牌需要严格保密,并只在必要时进行使用。解封密钥则是用于解密 Vault 中加密数据的重要凭据,可以用于解密 Vault 的存储密钥,解密后可以访问存储在 Vault 中的机密信息。因此,解封密钥也需要严格保密,通常会将其存储在冷存储中,以防止未经授权的访问和泄露。只有在必要时才使用解封密钥,例如在进行恢复操作或在创建新的存储密钥时。
三、centos7上部署和启动Vault的流程
在CentOS 7上部署和启动Vault可以按照以下步骤进行:
下载Vault二进制文件:可以从官网下载,也可以使用wget命令从Vault的GitHub页面下载。 安装Vault:将Vault二进制文件移到/usr/local/bin目录下,并添加执行权限。 配置Vault:可以在/etc目录下创建一个Vault配置文件,指定Vault的监听地址和端口,以及存储Vault数据的路径。 启动Vault:使用vault server命令启动Vault服务,会自动读取/etc目录下的配置文件并启动服务。 初始化Vault:使用vault init命令初始化Vault,生成一组Root Token和Unseal Key。 解封Vault:使用vault unseal命令输入Unseal Key解封Vault服务。 登录Vault:使用vault login命令输入Root Token登录Vault。
四、vault下载地址
vault下载地址:
vault官方下载地址选择下载的版本
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install vault
五、安装vault
执行命令:
sudo yum install -y yum-utils
sudo yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks, priorities, versionlock
Determining fastest mirrors
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
hashicorp | 1.4 kB 00:00:00
os | 3.6 kB 00:00:00
pgdg-common/7/x86_64/signature | 198 B 00:00:00
pgdg-common/7/x86_64/signature | 2.9 kB 00:00:00 !!!
pgdg11/7/x86_64/signature | 198 B 00:00:00
pgdg11/7/x86_64/signature | 3.6 kB 00:00:00 !!!
pgdg12/7/x86_64/signature | 198 B 00:00:00
pgdg12/7/x86_64/signature | 3.6 kB 00:00:00 !!!
pgdg13/7/x86_64/signature | 198 B 00:00:00
pgdg13/7/x86_64/signature | 3.6 kB 00:00:00 !!!
pgdg14/7/x86_64/signature | 198 B 00:00:00
pgdg14/7/x86_64/signature | 3.6 kB 00:00:00 !!!
pgdg15/7/x86_64/signature | 198 B 00:00:00
pgdg15/7/x86_64/signature | 3.6 kB 00:00:00 !!!
updates | 2.9 kB 00:00:00
(1/2): pgdg-common/7/x86_64/primary_db | 181 kB 00:00:02
(2/2): hashicorp/7/x86_64/primary | 165 kB 00:00:05
hashicorp 1196/1196
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do
执行命令:sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Loaded plugins: fastestmirror, langpacks, priorities, versionlock
adding repo from: https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
grabbing file https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo to /etc/yum.repos.d/hashicorp.repo
repo saved to /etc/yum.repos.d/hashicorp.repo
执行命令:sudo yum -y install vault
sudo yum -y install vault
Loaded plugins: fastestmirror, langpacks, priorities, versionlock
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package vault.x86_64 0:1.13.3-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================
Installing:
vault x86_64 1.13.3-1 hashicorp 92 M
Transaction Summary
==================================================================================================================================================
Install 1 Package
Total download size: 92 M
Installed size: 234 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/hashicorp/packages/vault-1.13.3-1.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a621e701: NOKEY00:00:00 ETA
Public key for vault-1.13.3-1.x86_64.rpm is not installed
vault-1.13.3-1.x86_64.rpm | 92 MB 00:00:24
Retrieving key from https://rpm.releases.hashicorp.com/gpg
Importing GPG key 0xA621E701:
Userid : "HashiCorp Security (HashiCorp Package Signing)
Fingerprint: 798a ec65 4e5c 1542 8c8e 42ee aa16 fcbc a621 e701
From : https://rpm.releases.hashicorp.com/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : vault-1.13.3-1.x86_64 1/1Generating Vault TLS key and self-signed certificate...
Generating a 4096 bit RSA private key
.......................++
.................................................................................................++
writing new private key to 'tls.key'
-----
Vault TLS key and self-signed certificate have been generated in '/opt/vault/tls'.
Verifying : vault-1.13.3-1.x86_64 1/1
Installed:
vault.x86_64 0:1.13.3-1
Complete!
六、启动Vault
执行启动命令:
vault server -dev -dev-root-token-id=“dev-only-token”
vault server -dev -dev-root-token-id="dev-only-token"
==> Vault server configuration:
Api Address: http://127.0.0.1:8200
Cgo: disabled
Cluster Address: https://127.0.0.1:8201
Environment Variables: CLASSPATH, FLINK_HOME, GODEBUG, HADOOP_HOME, HISTFILE, HISTSIZE, HISTTIMEFORMAT, HIVE_HOME, HOME, HOSTNAME, JAVA_HOME, LANG, LESSOPEN, LOGNAME, LS_COLORS, MAIL, MONGODB_HOME, MSSQL_HOME, PATH, PROMPT_COMMAND, PWD, PYTHON3_HOME, QT_GRAPHICSSYSTEM, QT_GRAPHICSSYSTEM_CHECKED, SHELL, SHLVL, SPARK_HOME, SUDO_COMMAND, SUDO_GID, SUDO_UID, SUDO_USER, TERM, TMOUT, USER, USERNAME, XDG_SESSION_ID, ZOOKEEP_HOME, _
Go Version: go1.20.4
Listener 1: tcp (addr: "127.0.0.1:8200", cluster address: "127.0.0.1:8201", max_request_duration: "1m30s", max_request_size: "33554432", tls: "disabled")
Log Level:
Mlock: supported: true, enabled: false
Recovery Mode: false
Storage: inmem
Version: Vault v1.13.3, built 2023-06-06T18:12:37Z
Version Sha: 3bedf816cbf851656ae9e6bd65dd4a67a9ddff5e
==> Vault server started! Log data will stream in below:
2023-06-19T10:38:19.735+0800 [INFO] proxy environment: http_proxy="" https_proxy="" no_proxy=""
2023-06-19T10:38:19.735+0800 [WARN] no `api_addr` value specified in config or in VAULT_API_ADDR; falling back to detection if possible, but this value should be manually set
2023-06-19T10:38:19.736+0800 [INFO] core: Initializing version history cache for core
2023-06-19T10:38:19.736+0800 [INFO] core: security barrier not initialized
2023-06-19T10:38:19.736+0800 [INFO] core: security barrier initialized: stored=1 shares=1 threshold=1
2023-06-19T10:38:19.737+0800 [INFO] core: post-unseal setup starting
2023-06-19T10:38:19.751+0800 [INFO] core: loaded wrapping token key
2023-06-19T10:38:19.751+0800 [INFO] core: successfully setup plugin catalog: plugin-directory=""
2023-06-19T10:38:19.751+0800 [INFO] core: no mounts; adding default mount table
2023-06-19T10:38:19.753+0800 [INFO] core: successfully mounted: type=cubbyhole version="v1.13.3+builtin.vault" path=cubbyhole/ namespace="ID: root. Path: "
2023-06-19T10:38:19.753+0800 [INFO] core: successfully mounted: type=system version="v1.13.3+builtin.vault" path=sys/ namespace="ID: root. Path: "
2023-06-19T10:38:19.754+0800 [INFO] core: successfully mounted: type=identity version="v1.13.3+builtin.vault" path=identity/ namespace="ID: root. Path: "
2023-06-19T10:38:19.755+0800 [INFO] core: successfully mounted: type=token version="v1.13.3+builtin.vault" path=token/ namespace="ID: root. Path: "
2023-06-19T10:38:19.756+0800 [INFO] rollback: starting rollback manager
2023-06-19T10:38:19.757+0800 [INFO] core: restoring leases
2023-06-19T10:38:19.758+0800 [INFO] expiration: lease restore complete
2023-06-19T10:38:19.758+0800 [INFO] identity: entities restored
2023-06-19T10:38:19.759+0800 [INFO] identity: groups restored
2023-06-19T10:38:19.759+0800 [INFO] core: Recorded vault version: vault version=1.13.3 upgrade time="2023-06-19 02:38:19.759135384 +0000 UTC" build date=2023-06-06T18:12:37Z
2023-06-19T10:38:19.981+0800 [INFO] core: post-unseal setup complete
2023-06-19T10:38:19.981+0800 [INFO] core: root token generated
2023-06-19T10:38:19.981+0800 [INFO] core: pre-seal teardown starting
2023-06-19T10:38:19.981+0800 [INFO] rollback: stopping rollback manager
2023-06-19T10:38:19.982+0800 [INFO] core: pre-seal teardown complete
2023-06-19T10:38:19.982+0800 [INFO] core.cluster-listener.tcp: starting listener: listener_address=127.0.0.1:8201
2023-06-19T10:38:19.982+0800 [INFO] core.cluster-listener: serving cluster requests: cluster_listen_address=127.0.0.1:8201
2023-06-19T10:38:19.982+0800 [INFO] core: post-unseal setup starting
2023-06-19T10:38:19.982+0800 [INFO] core: loaded wrapping token key
2023-06-19T10:38:19.982+0800 [INFO] core: successfully setup plugin catalog: plugin-directory=""
2023-06-19T10:38:19.983+0800 [INFO] core: successfully mounted: type=system version="v1.13.3+builtin.vault" path=sys/ namespace="ID: root. Path: "
2023-06-19T10:38:19.983+0800 [INFO] core: successfully mounted: type=identity version="v1.13.3+builtin.vault" path=identity/ namespace="ID: root. Path: "
2023-06-19T10:38:19.983+0800 [INFO] core: successfully mounted: type=cubbyhole version="v1.13.3+builtin.vault" path=cubbyhole/ namespace="ID: root. Path: "
2023-06-19T10:38:19.984+0800 [INFO] core: successfully mounted: type=token version="v1.13.3+builtin.vault" path=token/ namespace="ID: root. Path: "
2023-06-19T10:38:19.984+0800 [INFO] rollback: starting rollback manager
2023-06-19T10:38:19.984+0800 [INFO] core: restoring leases
2023-06-19T10:38:19.985+0800 [INFO] identity: entities restored
2023-06-19T10:38:19.985+0800 [INFO] identity: groups restored
2023-06-19T10:38:19.985+0800 [INFO] expiration: lease restore complete
2023-06-19T10:38:19.985+0800 [INFO] core: post-unseal setup complete
2023-06-19T10:38:19.985+0800 [INFO] core: vault is unsealed
2023-06-19T10:38:19.987+0800 [INFO] expiration: revoked lease: lease_id=auth/token/root/h272562f04a210e20b2b4d865e2a84db2d53929c149d30e4e06dcd93ebe88dbac
2023-06-19T10:38:19.989+0800 [INFO] core: successful mount: namespace="" path=secret/ type=kv version=""
WARNING! dev mode is enabled! In this mode, Vault runs entirely in-memory
and starts unsealed with a single unseal key. The root token is already
authenticated to the CLI, so you can immediately begin using Vault.
You may need to set the following environment variables:
$ export VAULT_ADDR='http://127.0.0.1:8200'
The unseal key and root token are displayed below in case you want to
seal/unseal the Vault or re-authenticate.
Unseal Key: DY/t5B7OSPzH1XZq5RJoEr0o7l4Ea5epNl9h0b/zaF4=
Root Token: dev-only-token
Development mode should NOT be used in production installations!
如上所示,成功启动Vault,至此成功安装部署Vault
注意命令行输出的解封密钥和根令牌,要妥善保存解封密钥和根令牌:
Unseal Key: DY/t5B7OSPzH1XZq5RJoEr0o7l4Ea5epNl9h0b/zaF4=Root Token: dev-only-token
七、总结和延伸
总结:
至此成功安装部署Vault
延展:
下一篇详细了解下如何应用安全工具Vault
优惠劵
最笨的羊羊
关注
关注
1
点赞
踩
8
收藏
觉得还不错?
一键收藏
打赏
知道了
0
评论
Vault从入门到精通系列之一:深入了解安全工具Vault、Vault根令牌和解封密钥,详细整理部署Vault的详细步骤
至此成功安装部署Vault下一篇详细了解下如何应用安全工具Vault。
复制链接
扫一扫
专栏目录
Vault部署保姆级教程
流浪法师的博客
06-27
1005
Vault部署教程,保姆级,
vault-cli:可配置的命令行界面工具(和python库),可与Hashicorp Vault进行交互
05-23
vault-cli :Hashicorp Vault的面向12因子的命令行工具
vault-cli是Python 3.6+工具,可提供简单的交互操作来操纵秘密。 使用vault-cli ,可以遵循原则将您的秘密保密。
一些功能
一次配置,由于级联(本地,用户,全局)YAML配置文件,可在任何地方使用
轻松阅读,浏览,书写,移动,删除秘密
以YAML形式一次读取多个机密
以您的秘密作为环境变量启动进程
使用从库中配置的ssh-agent启动进程
编写内部包含机密的模板文件
将多个秘密组合为一个秘密(例如,来自组件的DSN字符串)
vault-cli试图使访问秘密变得既安全又轻松。
展示柜
您可以使用vault-cli做以下几件事:
$ # Install:
$ pip install vault-cli
$ # Write a secret:
$ vault-cli set mysec
参与评论
您还未登录,请先
登录
后发表或查看评论
Vault从入门到精通系列之二:启动Vault服务器
zhengzaifeidelushang的博客
06-19
1261
Vault 作为客户端-服务器应用程序运行。Vault 服务器是唯一与数据存储和后端交互的 Vault 架构。通过 Vault CLI 完成的所有操作都通过 TLS 连接与服务器交互。在本篇博客中,启动以开发模式运行的 Vault 服务器并与之交互。
K8S使用helm部署vault集群
最新发布
ma_qi_chao的博客
12-22
1446
备注:为什么要进行vault初始化,如果不初始化,vault服务pod的READY会一直处于0/1状态,只有把vault的pod进行初始化生成初始token服务才会正常启动运行。备注:安装mysql只是测试vault加密的数据能否测试登录mysql,并不是把mysql作为vault数据库存储使用。以上完成了vault部署到测试的全部流程。
Vault: 基础教程之内置帮助及认证
博客
08-11
2706
四、内置帮助
现在你已经使用过键值对的密码引擎及AWS下的动态密码生成了,在两个例子之中,结构是使用都是不一样的,那么你要如何记住使用什么路径呢,vault里面有内置的帮助系统,可以通过api或者命令行访问,同时生成可读的帮助信息。
首先我们还是启用aws,通过vault secrets enable -path=aws aws来启用,然后即可使用vault path-help aws来查看路...
zfs-keyvault:systemd服务可从Azure Key Vault安全地加载ZFS加密密钥
02-02
zfs-keyvault
使用加密文件系统安全,自动解锁工具。
它是如何工作的?
简而言之,它等效于ZFS加密文件系统的network-online.target :
ZFS文件系统加密密钥放置在本地加密的密钥存储库中,该存储库自身的加密密钥放置在Azure Key Vault中。
引导后,系统服务会到达一个名为ZFS密钥网关的小型Flask Web应用程序,并请求存储库加密密钥。
ZFS密钥网关Web服务从人员获得授权,以通过Twilio SMS释放存储在Key Vault中的密钥存储库的加密密钥。 如果所有者通过回复SMS来授权请求,则会从Key Vault中检索密钥并将其发送回去。
系统现在可以解密本地存储库并安装加密的ZFS文件系统,而文件系统加密密钥永远不会离开设备。
产品特点
挂载ZFS加密的文件系统,而文件系统密钥不会离开设备
通过短信通知所有者,以批准任何关键请求
利用Azure Key Vault来安全存储存储库加密密钥
CLI工具,方便管理包含文件系统加密密钥的安全本地存储库
通过pexpect(stdin)将密钥安全地传递到ZFS
网关将关键请求
Vault: 基础教程之入门及使用介绍
热门推荐
博客
08-11
2万+
vault介绍
vault 是一个强大的密码管理工具,它基于命令行,是开源的。
vault是非常强大的,它具有如下特性:
1. 安全密码存储
2. 动态密码生成
3. 数据加密
4. 租期及更新
5. 废弃
下面来一步步介绍vault。
一、使用入门
首先我们使用vault server -dev开启vault的开发服务器,此服务器仅仅用于开发环境,生产环境下使用会导致不安...
Linux(Centos)旧版本操作系统配置旧版yum源(vault 源)的方法
你好帅(上局上段)
07-21
1634
旧版Centos操作系统在生存周期结束、停止维护后,官方会将旧版系统的yum源移动到的https//vault.centos.org中,使得旧版系统中配置的原有yum源往往会变得无法使用。2、打开https//mirrors.aliyun.com/repo/,找到与系统版本对应的源。curl-ohttps//mirrors.aliyun.com/repo/将系统的yum源改为为https//vault.centos.org中的源。...
Vault: 基础教程之部署
博客
08-11
4742
七、部署vault
配置
vault使用HCL文件配置:
storage "consul" {
address = "127.0.0.1:8500"
path = "vault/"
}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disa
MAC(m1)-Centos8建议切换centos-vault源
兴趣是最好的老师
01-04
187
Centos8(centos8官方源已下线,建议切换centos-vault源)
Vault-如何与运维体系融合
咖啡男孩之SRE之路
11-07
1474
上一篇《Vault-敏感信息保护的一种大胆尝试》介绍了解决运维体系中安全问题的一个基石地位的平台Vault,本篇跟大家分享下Vault如何与运维体系集成和联动。
vault-token-helper:适用于macOS,Linux和Windows的@Hashicorp Vault令牌帮助器,支持安全令牌存储和多个Vault服务器:locked_with_key:
05-15
保管库令牌帮助器
@hashicorp Vault,支持在macOS,Linux和Windows上的本机秘密存储。
特征
存储和检索多个Vault( $VAULT_ADDR )实例的令牌,简化了使用多个Vault时操作员的工作流程。
支持的后端:
macOS钥匙串
Linux(兼容DBus Secret Service的后端,例如:Gnome Keyring)
Windows(WinCred)
(GPG)
快速入门(macOS)
安装:
brew install joemiller/taps/vault-token-helper
配置Vault以使用令牌帮助器。 这将创建~/.vault配置文件:
vault-token-helper enable
向Vault实例进行身份验证以在本地加密和存储新令牌,例如使用Okta auth后端:
export VAULT_AD
aws-vault:用于在开发环境中安全存储和访问AWS凭证的保险库
01-30
AWS保险柜
AWS Vault是在开发环境中安全存储和访问AWS凭证的工具。
AWS Vault会将IAM凭证存储在操作系统的安全密钥库中,然后从这些凭证中生成临时凭证,以暴露给您的Shell和应用程序。 它被设计为对AWS CLI工具的补充,并且了解。
查看更多信息。
正在安装
您可以安装AWS Vault:
通过下载
在带有macOS上: brew install --cask aws-vault
在具有macOS上: port install aws-vault
在Windows上使用 : choco install aws-vault
在带有Windows上: scoop install aws-vault
在Linux上使用: brew install aws-vault
在: pacman -S aws-vault
在: pkg install aws-vault
使用 : nix-env -i aws-vault
文献资料
文件中提供了配置,用法,提示和技巧。
后端存储
支持的保管库后端是:
特勤局( , )
加密文件
使用--backend标
vault-init:初始化HashiCorp Vault并将根令牌和密钥保存在您选择的提供程序中
02-18
保管库初始化
初始化HashiCorp Vault并将根令牌和密钥保存在您选择的提供程序中。
docker pull ghcr.io/pbar1/vault-init
用法
可以识别(例如VAULT_ADDR , VAULT_CACERT等)。
Usage of vault-init:
--file-path string Path on disk to save the Vault init result (default "vault-init.json")
--kube-secret-annotations stringToString Labels to add to the Kubernetes secret (default [])
--kube-secret-labels strin
如何使用 Vault 安全地存储配置的 secret
华章IT官方博客
05-04
782
导读:每一个应用程序都有需要保密的信息,这些信息可能包括数据库凭证,外部服务认证,甚至某些资源的位置。所有这些都统称为密钥。应用程序需要一个安全的地方来存储这些密钥,无论是在应用程序启动时...
Vault实战(一)-Vault介绍
sre救赎之路
12-20
954
Vault 是一个基于身份的秘密和加密管理系统。秘密是您想要严格控制访问的任何内容,例如 API 加密密钥、密码和证书。Vault 提供由身份验证和授权方法控制的加密服务。使用 Vault 的 UI、CLI 或 HTTP API,可以安全地存储和管理、严格控制(限制)和审核对机密和其他敏感数据的访问。
vault配置指南
雾里华的博客
01-04
808
vault配置指南
Vault使用教程
bhwqq的博客
12-05
1154
本地开发环境启动client server ,开发环境的server 数据都保存在内存中,且交互式的内容都是没有tls协议加密的 ,请不要在生产环境运行dev环境
生产环境的数据应该都保存在磁盘或者consul里。
vault server -dev //需要记录下这个命令下的Unsealed key 和 access key
秘钥如下:
Unseal Key: uDJZKpkZ0bvfPd3LnFmRLNgAQN8DNPBMeQQSMR//trk=
Root Token: s.H5lx3jTkUrdOM
CentOS-8.5.2111 Boot版安装流程(配置yum源、配置远程连接、服务自启动)
林木无可栖的博客
07-06
3905
旨在创建一个轻量化的CentOS-8.5环境
The PersistentVolume "pv-vault-test01-vault1001" is invalid: spec.nodeAffinity: Required value: Local volume requires node affinity 配置文件案例
05-26
下面是一个示例的 PV 配置文件,其中使用了 nodeAffinity 来指定本地存储卷的节点: ``` apiVersion: v1 kind: PersistentVolume metadata: name: pv-vault-test01-vault1001 spec: capacity: storage: 10Gi ...
“相关推荐”对你有帮助么?
非常没帮助
没帮助
一般
有帮助
非常有帮助
提交
最笨的羊羊
CSDN认证博客专家
CSDN认证企业博客
码龄7年
大数据领域新星创作者
1867
原创
1068
周排名
457
总排名
208万+
访问
等级
2万+
积分
3万+
粉丝
2428
获赞
305
评论
4503
收藏
私信
关注
热门文章
深入了解海豚调度DolphinScheduler
48157
能ping通服务器,但telnet不通22端口问题解决方法汇总
21892
Mac系列之:Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW
21573
Zabbix5 安装教程
16579
MAC打开软件报错:无法验证开发者的解决方法
15907
分类专栏
软考高级系统架构设计师考试
付费
232篇
debezium
付费
289篇
flume
付费
57篇
前端和后端开发
付费
121篇
大数据
付费
522篇
Ansible、Docker、K8S、服务器相关知识总结
付费
64篇
数据库
付费
49篇
软考高级信息系统项目管理师考试
付费
93篇
PMP项目管理
付费
41篇
软考高级系统分析师
付费
12篇
zeppelin
付费
25篇
大数据平台二次开发
付费
103篇
数据中台开发实战总结
付费
9篇
Kafka
付费
49篇
日常分享专栏
421篇
金融知识总结
27篇
全面解析企业财务报表
5篇
软考信息系统项目管理师考试
Flink
56篇
Scala
1篇
面试题分享专栏
28篇
Java
8篇
数据分析
6篇
雅思学习每日知识分享
python
最新评论
Debezium报错处理系列之二十二:SchemaBuilderException: Cannot create field because of field name duplication
最笨的羊羊:
私信我下报错,帮你看下
Debezium报错处理系列之二十二:SchemaBuilderException: Cannot create field because of field name duplication
试试顶顶顶:
大佬能解答一下吗,被困扰好久了
数据库系列之:什么是 SAP HANA?
CSDN-Ada助手:
MySQL入门 技能树或许可以帮到你:https://edu.csdn.net/skill/mysql?utm_source=AI_act_mysql
Debezium报错处理系列之二十二:SchemaBuilderException: Cannot create field because of field name duplication
试试顶顶顶:
大佬,问一下,为什么我设置了这两个参数后,重启任务依旧是不行的
Flink系列之:JDBC SQL 连接器
lgq-tzq:
我想问一下,在flink sql里面建的那张mysql的表,是不是可以用navicat连接数据库,然后看到这个表
最新文章
金融知识分析系列之:净资产收益率、权益乘数、公允价值、总资产周转率、每股收益、扣除非经常性损益后净利润、归属于母公司所有者的扣除非经常性损益净利润、少数股东权益
上市公司财务报表精讲系列一:黄山旅游
Debezium日常分享系列之:Debezium 2.6.0.Beta1发布
2024
03月
18篇
02月
29篇
01月
18篇
2023年555篇
2022年518篇
2021年491篇
2020年191篇
2019年48篇
目录
目录
分类专栏
软考高级系统架构设计师考试
付费
232篇
debezium
付费
289篇
flume
付费
57篇
前端和后端开发
付费
121篇
大数据
付费
522篇
Ansible、Docker、K8S、服务器相关知识总结
付费
64篇
数据库
付费
49篇
软考高级信息系统项目管理师考试
付费
93篇
PMP项目管理
付费
41篇
软考高级系统分析师
付费
12篇
zeppelin
付费
25篇
大数据平台二次开发
付费
103篇
数据中台开发实战总结
付费
9篇
Kafka
付费
49篇
日常分享专栏
421篇
金融知识总结
27篇
全面解析企业财务报表
5篇
软考信息系统项目管理师考试
Flink
56篇
Scala
1篇
面试题分享专栏
28篇
Java
8篇
数据分析
6篇
雅思学习每日知识分享
python
目录
评论
被折叠的 条评论
为什么被折叠?
到【灌水乐园】发言
查看更多评论
添加红包
祝福语
请填写红包祝福语或标题
红包数量
个
红包个数最小为10个
红包总金额
元
红包金额最低5元
余额支付
当前余额3.43元
前往充值 >
需支付:10.00元
取消
确定
下一步
知道了
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝
规则
hope_wisdom 发出的红包
打赏作者
最笨的羊羊
你的鼓励将是我创作的最大动力
¥1
¥2
¥4
¥6
¥10
¥20
扫码支付:¥1
获取中
扫码支付
您的余额不足,请更换扫码支付或充值
打赏作者
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额
0
抵扣说明:
1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。 2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。
余额充值
VAULT中文(繁体)翻译:剑桥词典
VAULT中文(繁体)翻译:剑桥词典
词典
翻译
语法
同义词词典
+Plus
剑桥词典+Plus
Shop
剑桥词典+Plus
我的主页
+Plus 帮助
退出
剑桥词典+Plus
我的主页
+Plus 帮助
退出
登录
/
注册
中文 (简体)
查找
查找
英语-中文(繁体)
vault 在英语-中文(繁体)词典中的翻译
vaultnoun [ C ] uk
Your browser doesn't support HTML5 audio
/vɒlt/ us
Your browser doesn't support HTML5 audio
/vɑːlt/
vault noun [C]
(ARCH)
Add to word list
Add to word list
a type of arch that supports a roof or ceiling, especially in a church or public building, or a ceiling or roof supported by several of these arches
(尤指教堂或公共建築的)拱頂,穹頂
vault noun [C]
(ROOM)
(UK also vaults) a room, especially in a bank, with thick walls and a strong door, used to store money or valuable things in safe conditions
(尤指銀行的)金庫,保險庫
a bank vault
銀行金庫
She entered the vault with an armed guard.
她同一名武裝保安一起進入了金庫。
a room under a church or a small building in a cemetery where dead bodies are buried
(教堂的)地下墓室;(墓地的)墓穴
She was buried in the family vault.
她被葬在家族墓室裡。
vaultverb uk
Your browser doesn't support HTML5 audio
/vɒlt/ us
Your browser doesn't support HTML5 audio
/vɑːlt/
[ I usually + adv/prep, T ] to jump over something by first putting your hands on it or by using a pole
(用手支撐或撐杆)跳躍,躍過
He vaulted over the gate.
他從那扇大門上翻了過去。
She vaulted the wall and kept running.
她躍過了那堵牆繼續往前跑。
He has vaulted 6.02 m in indoor competitions this year.
在今年的室內比賽中他躍過了6.02米的高度。
也请参见
pole vault
[ T ] formal to move someone or something suddenly to a much more important position
突然提升;使躍居
Last week's changes vaulted the general to the top, over the heads of several of his seniors.
上週的變動使這位將軍一下子超過他的幾位上司而躍居最高層。
(vault在剑桥英语-中文(繁体)词典的翻译 © Cambridge University Press)
vault的例句
vault
In lateral view, larvae slightly and almost symmetrically vaulted; glabella and protopygidial axis inflated.
来自 Cambridge English Corpus
Gravestones became more splendid and monumental, amplifying the perspective not just of the family vaults but also of the whole parish architectural landscape.
来自 Cambridge English Corpus
I am told that one of the big joint stock banks have over £20,000,000 now on deposit, unused, in its own vaults.
来自 Hansard archive
该例句来自Hansard存档。包含以下议会许可信息开放议会许可v3.0
Children play around in this area, but there are broken vaults and fallen gravestones.
来自 Hansard archive
该例句来自Hansard存档。包含以下议会许可信息开放议会许可v3.0
They have cellars and vaults full of pictures for which no display space is available.
来自 Europarl Parallel Corpus - English
When such vaults are distressed, however, they may finally reveal the secrets of their construction by their patterns of cracks.
来自 Cambridge English Corpus
The vault's collapse changed the original location of the human remains and the offerings.
来自 Cambridge English Corpus
Comprising three storeys and underground vaults, it was built in the early 14th century, but still has two complete rooms.
来自 Hansard archive
该例句来自Hansard存档。包含以下议会许可信息开放议会许可v3.0
示例中的观点不代表剑桥词典编辑、剑桥大学出版社和其许可证颁发者的观点。
B1
vault的翻译
中文(简体)
拱, (尤指教堂或公共建筑的)拱顶,穹顶, 房间…
查看更多内容
西班牙语
bóveda, cámara acorazada, cripta…
查看更多内容
葡萄牙语
abóbada, casa-forte, caixa-forte…
查看更多内容
更多语言
土耳其语
法语
in Dutch
捷克语
丹麦语
印尼语
泰语
越南语
波兰语
in Swedish
马来语
德语
挪威语
in Ukrainian
俄语
kasa dairesi, (kilise) mezar odası, sıçramak…
查看更多内容
cave voûtée, chambre forte, caveau…
查看更多内容
gewelf, kluis, grafkelder…
查看更多内容
sklepení, trezor, hrobka…
查看更多内容
hvælving, boks, -boks…
查看更多内容
ruangan besar, gudang bawah tanah, ruang kuburan keluarga…
查看更多内容
หลังคาโค้ง, ห้องใต้ถุน, ที่ฝังศพของสกุล…
查看更多内容
vòm, mái vòm, hầm…
查看更多内容
skarbiec, krypta, grobowiec…
查看更多内容
källarvalv, kassavalv, gravvalv…
查看更多内容
kekubah, bilik kebal, makam…
查看更多内容
das Gewölbe, die Stahlkammer, die Gruft…
查看更多内容
hvelv, kjeller, (bank)hvelv…
查看更多内容
склепіння, підвал, льох…
查看更多内容
хранилище (в банке), склеп, перепрыгивать…
查看更多内容
需要一个翻译器吗?
获得快速、免费的翻译!
翻译器工具
vault的发音是什么?
在英语词典中查看 vault 的释义
浏览
vat
VATable
Vatican City
vaudeville
vault
vaulted
vaulting
vaunt
vaunted
vault更多的中文(繁体)翻译
全部
pole vault
查看全部意思»
“每日一词”
veggie burger
UK
Your browser doesn't support HTML5 audio
/ˈvedʒ.i ˌbɜː.ɡər/
US
Your browser doesn't support HTML5 audio
/ˈvedʒ.i ˌbɝː.ɡɚ/
a type of food similar to a hamburger but made without meat, by pressing together small pieces of vegetables, seeds, etc. into a flat, round shape
关于这个
博客
Forget doing it or forget to do it? Avoiding common mistakes with verb patterns (2)
March 06, 2024
查看更多
新词
stochastic parrot
March 04, 2024
查看更多
已添加至 list
回到页面顶端
内容
英语-中文(繁体)例句翻译
©剑桥大学出版社与评估2024
学习
学习
学习
新词
帮助
纸质书出版
Word of the Year 2021
Word of the Year 2022
Word of the Year 2023
开发
开发
开发
词典API
双击查看
搜索Widgets
执照数据
关于
关于
关于
无障碍阅读
剑桥英语教学
剑桥大学出版社与评估
授权管理
Cookies与隐私保护
语料库
使用条款
京ICP备14002226号-2
©剑桥大学出版社与评估2024
剑桥词典+Plus
我的主页
+Plus 帮助
退出
词典
定义
清晰解释自然的书面和口头英语
英语
学习词典
基础英式英语
基础美式英语
翻译
点击箭头改变翻译方向。
双语词典
英语-中文(简体)
Chinese (Simplified)–English
英语-中文(繁体)
Chinese (Traditional)–English
英语-荷兰语
荷兰语-英语
英语-法语
法语-英语
英语-德语
德语-英语
英语-印尼语
印尼语-英语
英语-意大利语
意大利语-英语
英语-日语
日语-英语
英语-挪威语
挪威语-英语
英语-波兰语
波兰语-英语
英语-葡萄牙语
葡萄牙语-英语
英语-西班牙语
西班牙语-英语
English–Swedish
Swedish–English
半双语词典
英语-阿拉伯语
英语-孟加拉语
英语-加泰罗尼亚语
英语-捷克语
英语-丹麦语
English–Gujarati
英语-印地语
英语-韩语
英语-马来语
英语-马拉地语
英语-俄语
English–Tamil
English–Telugu
英语-泰语
英语-土耳其语
英语-乌克兰语
English–Urdu
英语-越南语
翻译
语法
同义词词典
Pronunciation
剑桥词典+Plus
Shop
剑桥词典+Plus
我的主页
+Plus 帮助
退出
登录 /
注册
中文 (简体)
Change
English (UK)
English (US)
Español
Русский
Português
Deutsch
Français
Italiano
中文 (简体)
正體中文 (繁體)
Polski
한국어
Türkçe
日本語
Tiếng Việt
हिंदी
தமிழ்
తెలుగు
关注我们
选择一本词典
最近的词和建议
定义
清晰解释自然的书面和口头英语
英语
学习词典
基础英式英语
基础美式英语
语法与同义词词典
对自然书面和口头英语用法的解释
英语语法
同义词词典
Pronunciation
British and American pronunciations with audio
English Pronunciation
翻译
点击箭头改变翻译方向。
双语词典
英语-中文(简体)
Chinese (Simplified)–English
英语-中文(繁体)
Chinese (Traditional)–English
英语-荷兰语
荷兰语-英语
英语-法语
法语-英语
英语-德语
德语-英语
英语-印尼语
印尼语-英语
英语-意大利语
意大利语-英语
英语-日语
日语-英语
英语-挪威语
挪威语-英语
英语-波兰语
波兰语-英语
英语-葡萄牙语
葡萄牙语-英语
英语-西班牙语
西班牙语-英语
English–Swedish
Swedish–English
半双语词典
英语-阿拉伯语
英语-孟加拉语
英语-加泰罗尼亚语
英语-捷克语
英语-丹麦语
English–Gujarati
英语-印地语
英语-韩语
英语-马来语
英语-马拉地语
英语-俄语
English–Tamil
English–Telugu
英语-泰语
英语-土耳其语
英语-乌克兰语
English–Urdu
英语-越南语
词典+Plus
词汇表
选择语言
中文 (简体)
English (UK)
English (US)
Español
Русский
Português
Deutsch
Français
Italiano
正體中文 (繁體)
Polski
한국어
Türkçe
日本語
Tiếng Việt
हिंदी
தமிழ்
తెలుగు
内容
英语-中文(繁体)
Noun
vault (ARCH)
vault (ROOM)
Verb
例句
Translations
语法
所有翻译
我的词汇表
把vault添加到下面的一个词汇表中,或者创建一个新词汇表。
更多词汇表
前往词汇表
对该例句有想法吗?
例句中的单词与输入词条不匹配。
该例句含有令人反感的内容。
取消
提交
例句中的单词与输入词条不匹配。
该例句含有令人反感的内容。
取消
提交
secrets 管理工具 Vault 的介绍、安装及使用 - This Cute World
ets 管理工具 Vault 的介绍、安装及使用 - This Cute World阅读排行 系列 技术 生活 标签 朋友们 此刻 关于 Simplified ChineseSimplified Chinese
取消阅读排行系列技术生活标签朋友们此刻关于
Simplified Chinese
Simplified Chinese目录一、Vault 基础概念1. 数据存储及加密解密2. 认证系统及权限系统3. Secret Engine二、部署 Vault0. 如何选择存储后端?1. docker-compose 部署(非 HA)2. 通过 helm 部署高可用的 vault3. 初始化并解封 vault4. 初始化并设置自动解封三、Vault 自身的配置管理1. 使用 pulumi 自动化配置 vault1.1 Token 的生成四、在 Kubernetes 中使用 vault 注入 secrets1. 部署并配置 vault agent1.1 使用集群外部的 valut 实例2. 关联 k8s rbac 权限系统和 vault3. 部署 Pod4. vault agent 配置5. 拓展:在 kubernetes 中使用 vault 的其他姿势五、使用 vault 实现 AWS IAM Credentials 的自动轮转secrets 管理工具 Vault 的介绍、安装及使用ryan4yin
收录于 类别 tech 和 系列 写给开发人员的实用密码学 云原生相关 2021-01-24 2021-01-24 约 8631 字 预计阅读 18 分钟 系列 - 云原生相关
FinOps for Kubernetes - 如何拆分 Kubernetes 成本部署一个 Kubernetes 集群Kubernetes 微服务最佳实践云原生流水线 Argo Workflows 的安装、使用以及个人体验Pulumi 使用体验 - 基础设施代码化使用 Istio 进行 JWT 身份验证(充当 API 网关)Kubernetes 常见错误、原因及处理方法secrets 管理工具 Vault 的介绍、安装及使用Kubernetes 中的证书管理工具 - cert-manager系列 - 写给开发人员的实用密码学
写给开发人员的实用密码学(一)—— 概览写给开发人员的实用密码学(二)—— 哈希函数写给开发人员的实用密码学(三)—— MAC 与密钥派生函数 KDF写给开发人员的实用密码学(四)—— 安全随机数生成器 CSPRNG写给开发人员的实用密码学(五)—— 密钥交换 DHKE 与完美前向保密 PFS写给开发人员的实用密码学(六)—— 对称密钥加密算法写给开发人员的实用密码学(七)—— 非对称密钥加密算法 RSA/ECC写给开发人员的实用密码学(八)—— 数字证书与 TLS 协议secrets 管理工具 Vault 的介绍、安装及使用Kubernetes 中的证书管理工具 - cert-manager个人数据安全不完全指南目录
一、Vault 基础概念1. 数据存储及加密解密2. 认证系统及权限系统3. Secret Engine二、部署 Vault0. 如何选择存储后端?1. docker-compose 部署(非 HA)2. 通过 helm 部署高可用的 vault3. 初始化并解封 vault4. 初始化并设置自动解封三、Vault 自身的配置管理1. 使用 pulumi 自动化配置 vault1.1 Token 的生成四、在 Kubernetes 中使用 vault 注入 secrets1. 部署并配置 vault agent1.1 使用集群外部的 valut 实例2. 关联 k8s rbac 权限系统和 vault3. 部署 Pod4. vault agent 配置5. 拓展:在 kubernetes 中使用 vault 的其他姿势五、使用 vault 实现 AWS IAM Credentials 的自动轮转Vault 是 hashicorp 推出的 secrets 管理、加密即服务与权限管理工具。它的功能简介如下:secrets 管理:支持保存各种自定义信息、自动生成各类密钥,vault 自动生成的密钥还能自动轮转(rotate)认证方式:支持接入各大云厂商的账号体系(比如阿里云RAM子账号体系)或者 LDAP 等进行身份验证,不需要创建额外的账号体系。权限管理:通过 policy,可以设定非常细致的 ACL 权限。密钥引擎:也支持接管各大云厂商的账号体系(比如阿里云RAM子账号体系),实现 API Key 的自动轮转。支持接入 kubernetes rbac 认证体系,通过 serviceaccount+role 为每个 Pod 单独配置认证角色。支持通过 sidecar/init-container 将 secrets 注入到 pod 中,或者通过 k8s operator 将 vault 数据同步到 k8s secrets 中在使用 Vault 之前,我们是以携程开源的 Apollo 作为微服务的分布式配置中心。Apollo 在国内非常流行。它功能强大,支持配置的继承,也有提供 HTTP API 方便自动化。
缺点是权限管理和 secrets 管理比较弱,也不支持信息加密,不适合直接存储敏感信息。因此我们现在切换到了 Vault.目前我们本地的 CI/CD 流水线和云上的微服务体系,都是使用的 Vault 做 secrets 管理.一、Vault 基础概念「基本概念」这一节,基本都翻译自官方文档: https://www.vaultproject.io/docs/internals/architecture首先看一下 Vault 的架构图:vault layers可以看到,几乎所有的 Vault 组件都被统称为「屏障(Barrier)」。Vault 可以简单地被划分为存储后端(Storage Backend)、屏障(Barrier)和 HTTP/S API 三个部分。Vault,翻译成中文就是金库。类比银行金库,「屏障」就是用于保护金库的合金大门和钢筋混凝土,存储后端和客户端之间的所有数据流动都需要经过它。「屏障」确保只有加密数据会被写入存储后端,加密数据在经过「屏障」被读出的过程中被验证与解密。和银行金库的大门非常类似,「屏障」也必须先解封,才能解密存储后端中的数据。1. 数据存储及加密解密存储后端(Storage Backend): Vault 自身不存储数据,因此需要为它配置一个存储后端。
存储后端是不受信任的,只用于存储加密数据。初始化(Initialization): Vault 在首次启动时需要初始化,这一步生成一个加密密钥(Encryption Key)用于加密数据,加密完成的数据才能被保存到存储后端。解封(Unseal): Vault 启动后,因为不知道加密密钥所以无法解密数据,这种状态被形象得称作已封印(Sealed)。在解封前 Vault 无法进行任何操作。加密密钥被主密钥(Master Key)保护,我们必须提供主密钥才能解密出 Vault 的加密密钥,从而完成解封操作。默认情况下,Vault 使用沙米尔密钥分割算法
将主密钥分割成五个分割密钥(Key Shares),必须要提供其中任意三个分割密钥才能重建出主密钥,完成解封操作。vault-shamir-secret-sharing分割密钥的总数,以及重建主密钥最少需要的分割密钥数量,都是可以调整的。
沙米尔密钥分割算法也可以关闭,这样主密钥将被直接提供给管理员,管理员可直接使用它进行解封操作。2. 认证系统及权限系统在解封完成后,Vault 就可以开始处理请求了。HTTP 请求进入后的整个处理流程都由 vault core 管理,core 会强制进行 ACL 检查,并确保审计日志(audit logging)完成记录。客户端首次连接 vault 时,需要先完成身份认证,vault 的 auth methods 模块有很多身份认证方法可选:用户友好的认证方法,适合管理员使用:username/password、云服务商、ldap在创建 user 的时候,需要为 user 绑定 policy,给予合适的权限。应用友好的方法,适合应用程序使用:public/private keys、tokens、kubernetes、jwt身份验证请求流经 core 并进入 auth methods,auth methods 确定请求是否有效并返回「关联策略(policies)」的列表。ACL 策略由 policy store 负责管理与存储,由 core 进行 ACL 检查。
ACL 的默认行为是拒绝,这意味着除非明确配置 policy 允许某项操作,否则该操作将被拒绝。在通过 auth methods 完成了身份认证,并且返回的关联策略也没毛病之后,token store 将会生成并管理一个新的凭证(token),
这个 token 会被返回给客户端,用于进行后续请求。类似 web 网站的 cookie,token 也都存在一个租期(lease)或者说有效期,这加强了安全性。token 关联了相关的策略 policies,这些策略将被用于验证请求的权限。请求经过验证后,将被路由到 secret engine。如果 secret engine 返回了一个 secret(由 vault 自动生成的 secret),
core 会将其注册到 expiration manager,并给它附加一个 lease ID。lease ID 被客户端用于更新(renew)或吊销(revoke)它得到的 secret.如果客户端允许租约(lease)到期,expiration manager 将自动吊销这个 secret.core 还负责处理审核代理 audit broker的请求及响应日志,将请求发送到所有已配置的审核设备 audit devices. 不过默认情况下这个功能貌似是关闭的。3. Secret EngineSecret Engine 是保存、生成或者加密数据的组件,它非常灵活。有的 Secret Engines 只是单纯地存储与读取数据,比如 kv 就可以看作一个加密的 Redis。
而其他的 Secret Engines 则连接到其他的服务并按需生成动态凭证。还有些 Secret Engines 提供「加密即服务(encryption as a service)」的能力,如 transit、证书管理等。常用的 engine 举例:AliCloud Secrets Engine: 基于 RAM 策略动态生成 AliCloud Access Token,或基于 RAM 角色动态生成 AliCloud STS 凭据Access Token 会自动更新(Renew),而 STS 凭据是临时使用的,过期后就失效了。kv: 键值存储,可用于存储一些静态的配置。它一定程度上能替代掉携程的 Apollo 配置中心。Transit Secrets Engine: 提供加密即服务的功能,它只负责加密和解密,不负责存储。主要应用场景是帮 app 加解密数据,但是数据仍旧存储在 MySQL 等数据库中。二、部署 Vault官方建议通过 Helm 部署 vault,大概流程:使用 helm/docker 部署运行 vault.初始化/解封 vault: vault 安全措施,每次重启必须解封(可设置自动解封).0. 如何选择存储后端?首先,我们肯定需要高可用 HA,至少要保留能升级到 HA 的能力,所以不建议选择不支持 HA 的后端。而具体的选择,就因团队经验而异了,人们往往倾向于使用自己熟悉的、知根知底的后端,或者选用云服务。比如我们对 MySQL/PostgreSQL 比较熟悉,而且使用云服务提供的数据库不需要考虑太多的维护问题,MySQL/PostgreSQL 作为一个通用协议也不会被云厂商绑架,那我们就倾向于使用这两者之一。而如果你们是本地自建,那你可能更倾向于使用 Etcd/Consul/Raft 做后端存储。1. docker-compose 部署(非 HA)推荐用于本地开发测试环境,或者其他不需要高可用的环境。docker-compose.yml 示例如下: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
version: '3.3'
services:
vault:
# 文档:https://hub.docker.com/_/vault
image: vault:1.6.0
container_name: vault
ports:
# rootless 容器,内部不能使用标准端口 443
- "443:8200"
restart: always
volumes:
# 审计日志存储目录(`file` audit backend)
- ./logs:/vault/logs
# 当使用 file data storage 插件时,数据被存储在这里。默认不往这写任何数据。
- ./file:/vault/file
# vault 配置
- ./config.hcl:/vault/config/config.hcl
# TLS 证书
- ./certs:/certs
# vault 需要锁定内存以防止敏感值信息被交换(swapped)到磁盘中
# 为此需要添加如下 capability
cap_add:
- IPC_LOCK
# 必须设定 entrypoint,否则 vault 容器默认以 development 模式运行
entrypoint: vault server -config /vault/config/config.hcl
config.hcl 内容如下: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
ui = true
// 使用文件做数据存储(单节点)
storage "file" {
path = "/vault/file"
}
listener "tcp" {
address = "[::]:8200"
tls_disable = false
tls_cert_file = "/certs/server.crt"
tls_key_file = "/certs/server.key"
}
将如上两份配置保存在同一文件夹内,同时在 ./certs 中提供 TLS 证书 server.crt 和私钥 server.key。然后 docker-compose up -d 就能启动运行一个 vault 实例。2. 通过 helm 部署高可用的 vault推荐用于生产环境通过 helm 部署:1
2
3
4
5
6
# 添加 valut 仓库
helm repo add hashicorp https://helm.releases.hashicorp.com
# 查看 vault 版本号
helm search repo hashicorp/vault -l | head
# 下载某个版本号的 vault
helm pull hashicorp/vault --version 0.11.0 --untar
参照下载下来的 ./vault/values.yaml 编写 custom-values.yaml,
部署一个以 mysql 为后端存储的 HA vault,配置示例如下:配置内容虽然多,但是大都是直接拷贝自 ./vault/values.yaml,改动很少。
测试 Vault 时可以忽略掉其中大多数的配置项。 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
global:
# enabled is the master enabled switch. Setting this to true or false
# will enable or disable all the components within this chart by default.
enabled: true
# TLS for end-to-end encrypted transport
tlsDisable: false
injector:
# True if you want to enable vault agent injection.
enabled: true
replicas: 1
# If true, will enable a node exporter metrics endpoint at /metrics.
metrics:
enabled: false
# Mount Path of the Vault Kubernetes Auth Method.
authPath: "auth/kubernetes"
certs:
# secretName is the name of the secret that has the TLS certificate and
# private key to serve the injector webhook. If this is null, then the
# injector will default to its automatic management mode that will assign
# a service account to the injector to generate its own certificates.
secretName: null
# caBundle is a base64-encoded PEM-encoded certificate bundle for the
# CA that signed the TLS certificate that the webhook serves. This must
# be set if secretName is non-null.
caBundle: ""
# certName and keyName are the names of the files within the secret for
# the TLS cert and private key, respectively. These have reasonable
# defaults but can be customized if necessary.
certName: tls.crt
keyName: tls.key
server:
# Resource requests, limits, etc. for the server cluster placement. This
# should map directly to the value of the resources field for a PodSpec.
# By default no direct resource request is made.
# Enables a headless service to be used by the Vault Statefulset
service:
enabled: true
# Port on which Vault server is listening
port: 8200
# Target port to which the service should be mapped to
targetPort: 8200
# This configures the Vault Statefulset to create a PVC for audit
# logs. Once Vault is deployed, initialized and unseal, Vault must
# be configured to use this for audit logs. This will be mounted to
# /vault/audit
# See https://www.vaultproject.io/docs/audit/index.html to know more
auditStorage:
enabled: false
# Run Vault in "HA" mode. There are no storage requirements unless audit log
# persistence is required. In HA mode Vault will configure itself to use Consul
# for its storage backend. The default configuration provided will work the Consul
# Helm project by default. It is possible to manually configure Vault to use a
# different HA backend.
ha:
enabled: true
replicas: 3
# Set the api_addr configuration for Vault HA
# See https://www.vaultproject.io/docs/configuration#api_addr
# If set to null, this will be set to the Pod IP Address
apiAddr: null
# config is a raw string of default configuration when using a Stateful
# deployment. Default is to use a Consul for its HA storage backend.
# This should be HCL.
# Note: Configuration files are stored in ConfigMaps so sensitive data
# such as passwords should be either mounted through extraSecretEnvironmentVars
# or through a Kube secret. For more information see:
# https://www.vaultproject.io/docs/platform/k8s/helm/run#protecting-sensitive-vault-configurations
config: |
ui = true
listener "tcp" {
address = "[::]:8200"
cluster_address = "[::]:8201"
# 注意,这个值要和 helm 的参数 global.tlsDisable 一致
tls_disable = false
tls_cert_file = "/etc/certs/vault.crt"
tls_key_file = "/etc/certs/vault.key"
}
# storage "postgresql" {
# connection_url = "postgres://username:password@
# ha_enabled = true
# }
service_registration "kubernetes" {}
# Example configuration for using auto-unseal, using AWS KMS.
# the cluster must have a service account that is authorized to access AWS KMS, throught an IAM Role.
# seal "awskms" {
# region = "us-east-1"
# kms_key_id = "
# 默认情况下插件会使用 awskms 的公网 enpoint,但是也可以使用如下参数,改用自行创建的 vpc 内网 endpoint
# endpoint = "https://
# }
# Definition of the serviceAccount used to run Vault.
# These options are also used when using an external Vault server to validate
# Kubernetes tokens.
serviceAccount:
create: true
name: "vault"
annotations:
# 如果要使用 auto unseal 的话,这个填写拥有 awskms 权限的 AWS IAM Role
eks.amazonaws.com/role-arn:
# Vault UI
ui:
enabled: true
publishNotReadyAddresses: true
serviceType: ClusterIP
activeVaultPodOnly: true
externalPort: 8200
现在使用自定义的 custom-values.yaml 部署 vautl:1
2
3
kubectl create namespace vault
# 安装/升级 valut
helm upgrade --install vault ./vault --namespace vault -f custom-values.yaml
3. 初始化并解封 vault官方文档:Initialize and unseal Vault - Vault on Kubernetes Deployment Guide通过 helm 部署 vault,默认会部署一个三副本的 StatefulSet,但是这三个副本都会处于 NotReady 状态(docker 方式部署的也一样)。
接下来还需要手动初始化并解封 vault,才能 Ready:第一步:从三个副本中随便选择一个,运行 vault 的初始化命令:kubectl exec -ti vault-0 -- vault operator init初始化操作会返回 5 个 unseal keys,以及一个 Initial Root Token,这些数据非常敏感非常重要,一定要保存到安全的地方!第二步:在每个副本上,使用任意三个 unseal keys 进行解封操作。一共有三个副本,也就是说要解封 3*3 次,才能完成 vault 的完整解封!1
2
3
4
5
# 每个实例都需要解封三次!
## Unseal the first vault server until it reaches the key threshold
$ kubectl exec -ti vault-0 -- vault operator unseal # ... Unseal Key 1
$ kubectl exec -ti vault-0 -- vault operator unseal # ... Unseal Key 2
$ kubectl exec -ti vault-0 -- vault operator unseal # ... Unseal Key 3
这样就完成了部署,但是要注意,vault 实例每次重启后,都需要重新解封!也就是重新进行第二步操作!4. 初始化并设置自动解封在未设置 auto unseal 的情况下,vault 每次重启都要手动解封所有 vault 实例,实在是很麻烦,在云上自动扩缩容的情况下,vault 实例会被自动调度,这种情况就更麻烦了。为了简化这个流程,可以考虑配置 auto unseal 让 vault 自动解封。自动解封目前有两种方法:使用阿里云/AWS/Azure 等云服务提供的密钥库来管理 encryption keyAWS: awskms Seal如果是 k8s 集群,vault 使用的 ServiceAccount 需要有权限使用 AWS KMS,它可替代掉 config.hcl 中的 access_key/secret_key 两个属性阿里云:alicloudkms Seal如果你不想用云服务,那可以考虑 autounseal-transit,这种方法使用另一个 vault 实例提供的 transit 引擎来实现 auto-unseal.简单粗暴:直接写个 crontab 或者在 CI 平台上加个定时任务去执行解封命令,以实现自动解封。不过这样安全性就不好说了。以使用 awskms 为例,首先创建 aws IAM 的 policy 内容如下: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VaultKMSUnseal",
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"kms:Encrypt",
"kms:DescribeKey"
],
"Resource": "*"
}
]
}
然后创建 IAM Role 绑定上面的 policy,并为 vault 的 k8s serviceaccount 创建一个 IAM Role,绑定上这个 policy.这样 vault 使用的 serviceaccount 自身就拥有了访问 awskms 的权限,也就不需要额外通过 access_key/secret_key 来访问 awskms.关于 IAM Role 和 k8s serviceaccount 如何绑定,参见官方文档:IAM roles for EKS service accounts完事后再修改好前面提供的 helm 配置,部署它,最后使用如下命令初始化一下:1
2
3
4
# 初始化命令和普通模式并无不同
kubectl exec -ti vault-0 -- vault operator init
# 会打印出一个 root token,以及五个 Recovery Key(而不是 Unseal Key)
# Recover Key 不再用于解封,但是重新生成 root token 等操作仍然会需要用到它.
然后就大功告成了,可以尝试下删除 vault 的 pod,新建的 Pod 应该会自动解封。三、Vault 自身的配置管理Vault 本身是一个复杂的 secrets 工具,它提供了 Web UI 和 CLI 用于手动管理与查看 Vault 的内容。但是作为一名 DevOps,我们当然更喜欢更自治的方法,这有两种选择:使用 vault 的 sdk: python-hvac使用 terraform-provider-vault 或者 pulumi-vault 实现 vault 配置的自动化管理。Web UI 适合手工操作,而 sdk/terraform-provider-vault 则适合用于自动化管理 vault.我们的测试环境就是使用 pulumi-vault 完成的自动化配置 vault policy 和 kubernetes role,然后自动化注入所有测试用的 secrets.1. 使用 pulumi 自动化配置 vault使用 pulumi 管理 vault 配置的优势是很大的,因为云上资源的敏感信息(数据库账号密码、资源 ID、RAM子账号)都是 pulumi 创建的。再结合使用 pulumi_valut,就能实现敏感信息自动生成后,立即保存到 vault 中,实现完全自动化。后续微服务就可以通过 kubernetes 认证,直接从 vault 读取敏感信息。或者是写入到本地的 vault 中留做备份,在需要的时候,管理员能登入进去查看相关敏感信息。1.1 Token 的生成pulumi_vault 本身挺简单的,声明式的配置嘛,直接用就是了。但是它一定要求提供 VAULT_TOKEN 作为身份认证的凭证(实测 userpass/approle 都不能直接使用,会报错 no vault token found),而且 pulumi 还会先生成临时用的 child token,然后用这个 child token
进行后续的操作。首先安全起见,肯定不应该直接提供 root token!root token 应该封存,除了紧急情况不应该启用。那么应该如何生成一个权限有限的 token 给 vault 使用呢?
我的方法是创建一个 userpass 账号,通过 policy 给予它有限的权限。
然后先手动(或者自动)登录获取到 token,再将 token 提供给 pulumi_vault 使用。这里面有个坑,就是必须给 userpass 账号创建 child token 的权限:1
2
3
4
5
6
7
8
path "local/*" {
capabilities = ["read", "list"]
}
// 允许创建 child token
path "auth/token/create" {
capabilities = ["create", "read", "update", "delete", "list"]
}
不给这个权限,pulumi_vault 就会一直报错。。然后还得给它「自动化配置」需要的权限,比如自动创建/更新 policy/secrets/kubernetes 等等,示例如下: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# To list policies - Step 3
path "sys/policy"
{
capabilities = ["read"]
}
# Create and manage ACL policies broadly across Vault
path "sys/policy/*"
{
capabilities = ["create", "read", "update", "delete", "list", "sudo"]
}
# List, create, update, and delete key/value secrets
path "secret/*"
{
capabilities = ["create", "read", "update", "delete", "list", "sudo"]
}
path "auth/kubernetes/role/*"
{
capabilities = ["create", "read", "update", "list"]
}
四、在 Kubernetes 中使用 vault 注入 secretsvault-k8s-auth-workflow前面提到过 vault 支持通过 Kubernetes 的 ServiceAccount 为每个 Pod 单独分配权限。应用程序有两种方式去读取 vault 中的配置:借助 Vault Sidecar,将 secrets 以文件的形式自动注入到 Pod 中,比如 /vault/secrets/config.jsonvault sidecar 在常驻模式下每 15 秒更新一次配置,应用程序可以使用 watchdog 实时监控 secrets 文件的变更。应用程序自己使用 SDK 直接访问 vault api 获取 secrets上述两种方式,都可以借助 Kubernetes ServiceAccount 进行身份验证和权限分配。下面以 Sidecar 模式为例,介绍如何将 secrets 以文件形式注入到 Pod 中。1. 部署并配置 vault agent首先启用 Vault 的 Kubernetes 身份验证: 1
2
3
4
5
6
7
8
9
10
11
12
13
# 配置身份认证需要在 vault pod 中执行,启动 vault-0 的交互式会话
kubectl exec -n vault -it vault-0 -- /bin/sh
export VAULT_TOKEN='
export VAULT_ADDR='http://localhost:8200'
# 启用 Kubernetes 身份验证
vault auth enable kubernetes
# kube-apiserver API 配置,vault 需要通过 kube-apiserver 完成对 serviceAccount 的身份验证
vault write auth/kubernetes/config \
token_reviewer_jwt="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \
kubernetes_host="https://$KUBERNETES_PORT_443_TCP_ADDR:443" \
kubernetes_ca_cert=@/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
1.1 使用集群外部的 valut 实例如果你没这个需求,请跳过这一节。详见 Install the Vault Helm chart configured to address an external Vaultkubernetes 也可以和外部的 vault 实例集成,集群中只部署 vault-agent.这适用于多个 kubernetes 集群以及其他 APP 共用一个 vault 实例的情况,比如我们本地的多个开发测试集群,就都共用着同一个 vault 实例,方便统一管理应用的 secrets.首先,使用 helm chart 部署 vault-agent,接入外部的 vault 实例。使用的 custom-values.yaml 示例如下: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
global:
# enabled is the master enabled switch. Setting this to true or false
# will enable or disable all the components within this chart by default.
enabled: true
# TLS for end-to-end encrypted transport
tlsDisable: false
injector:
# True if you want to enable vault agent injection.
enabled: true
replicas: 1
# If multiple replicas are specified, by default a leader-elector side-car
# will be created so that only one injector attempts to create TLS certificates.
leaderElector:
enabled: true
image:
repository: "gcr.io/google_containers/leader-elector"
tag: "0.4"
ttl: 60s
# If true, will enable a node exporter metrics endpoint at /metrics.
metrics:
enabled: false
# External vault server address for the injector to use. Setting this will
# disable deployment of a vault server along with the injector.
# TODO 这里的 https ca.crt 要怎么设置?mTLS 又该如何配置?
externalVaultAddr: "https://
# Mount Path of the Vault Kubernetes Auth Method.
authPath: "auth/kubernetes"
certs:
# secretName is the name of the secret that has the TLS certificate and
# private key to serve the injector webhook. If this is null, then the
# injector will default to its automatic management mode that will assign
# a service account to the injector to generate its own certificates.
secretName: null
# caBundle is a base64-encoded PEM-encoded certificate bundle for the
# CA that signed the TLS certificate that the webhook serves. This must
# be set if secretName is non-null.
caBundle: ""
# certName and keyName are the names of the files within the secret for
# the TLS cert and private key, respectively. These have reasonable
# defaults but can be customized if necessary.
certName: tls.crt
keyName: tls.key
部署命令和 通过 helm 部署 vault 一致,只要更换 custom-values.yaml 就行。vault-agent 部署完成后,第二步是为 vault 创建 serviceAccount、secret 和 ClusterRoleBinding,以允许 vault 审查 kubernetes 的 token, 完成对 pod 的身份验证. yaml 配置如下: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: vault-auth
namespace: vault
---
apiVersion: v1
kind: Secret
metadata:
name: vault-auth
namespace: vault
annotations:
kubernetes.io/service-account.name: vault-auth
type: kubernetes.io/service-account-token
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: role-tokenreview-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: vault-auth
namespace: vault
现在在 vault 实例这边,启用 kubernetes 身份验证,在 vault 实例内,执行如下命令:vault 实例内显然没有 kubectl 和 kubeconfig,简便起见,下列的 vault 命令也可以通过 Web UI 完成。 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export VAULT_TOKEN='
export VAULT_ADDR='http://localhost:8200'
# 启用 Kubernetes 身份验证
vault auth enable kubernetes
# kube-apiserver API 配置,vault 需要通过 kube-apiserver 完成对 serviceAccount 的身份验证
# TOKEN_REVIEW_JWT: 就是我们前面创建的 secret `vault-auth`
TOKEN_REVIEW_JWT=$(kubectl -n vault get secret vault-auth -o go-template='{{ .data.token }}' | base64 --decode)
# kube-apiserver 的 ca 证书
KUBE_CA_CERT=$(kubectl -n vault config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}' | base64 --decode)
# kube-apiserver 的 url
KUBE_HOST=$(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.server}')
vault write auth/kubernetes/config \
token_reviewer_jwt="$TOKEN_REVIEW_JWT" \
kubernetes_host="$KUBE_HOST" \
kubernetes_ca_cert="$KUBE_CA_CERT"
这样,就完成了 kubernetes 与外部 vault 的集成!2. 关联 k8s rbac 权限系统和 vault接下来需要做的事:通过 vault policy 定义好每个 role(微服务)能访问哪些资源。为每个微服务生成一个 role,这个 role 需要绑定对应的 vault policy 及 kubernetes serviceaccount这个 role 是 vault 的 kubernetes 插件自身的属性,它和 kubernetes role 没有半毛钱关系。创建一个 ServiceAccount,并使用这个 使用这个 ServiceAccount 部署微服务其中第一步和第二步都可以通过 vault api 自动化完成.
第三步可以通过 kubectl 部署时完成。方便起见,vault policy / role / k8s serviceaccount 这三个配置,都建议和微服务使用相同的名称。上述配置中,role 起到一个承上启下的作用,它关联了 k8s serviceaccount 和 vault policy 两个配置。比如创建一个名为 my-app-policy 的 vault policy,内容为:1
2
3
4
5
6
7
8
# 允许读取数据
path "my-app/data/*" {
capabilities = ["read", "list"]
}
// 允许列出 myapp 中的所有数据(kv v2)
path "myapp/metadata/*" {
capabilities = ["read", "list"]
}
然后在 vault 的 kuberntes 插件配置中,创建 role my-app-role,配置如下:关联 k8s default 名字空间中的 serviceaccount my-app-account,并创建好这个 serviceaccount.关联 vault token policy,这就是前面创建的 my-app-policy设置 token period(有效期)这之后,每个微服务就能通过 serviceaccount 从 vault 中读取 my-app 中的所有信息了。3. 部署 Pod参考文档:https://www.vaultproject.io/docs/platform/k8s/injector下一步就是将配置注入到微服务容器中,这需要使用到 Agent Sidecar Injector。
vault 通过 sidecar 实现配置的自动注入与动态更新。具体而言就是在 Pod 上加上一堆 Agent Sidecar Injector 的注解,如果配置比较多,也可以使用 configmap 保存,在注解中引用。需要注意的是 vault-inject-agent 有两种运行模式:init 模式: 仅在 Pod 启动前初始化一次,跑完就退出(Completed)常驻模式: 容器不退出,持续监控 vault 的配置更新,维持 Pod 配置和 vualt 配置的同步。示例: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: my-app
name: my-app
namespace: default
spec:
minReadySeconds: 3
progressDeadlineSeconds: 60
revisionHistoryLimit: 3
selector:
matchLabels:
app: my-app
strategy:
rollingUpdate:
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
annotations:
vault.hashicorp.com/agent-init-first: 'true' # 是否使用 initContainer 提前初始化配置文件
vault.hashicorp.com/agent-inject: 'true'
vault.hashicorp.com/secret-volume-path: vault
vault.hashicorp.com/role: "my-app-role" # vault kubernetes 插件的 role 名称
vault.hashicorp.com/agent-inject-template-config.json: |
# 渲染模板的语法在后面介绍
vault.hashicorp.com/agent-limits-cpu: 250m
vault.hashicorp.com/agent-requests-cpu: 100m
# 包含 vault 配置的 configmap,可以做更精细的控制
# vault.hashicorp.com/agent-configmap: my-app-vault-config
labels:
app: my-app
spec:
containers:
- image: registry.svc.local/xx/my-app:latest
imagePullPolicy: IfNotPresent
# 此处省略若干配置...
serviceAccountName: my-app-account
常见错误:vault-agent(sidecar) 报错: namespace not authorizedauth/kubernetes/config 中的 role 没有绑定 Pod 的 namespacevault-agent(sidecar) 报错: permission denied检查 vault 实例的日志,应该有对应的错误日志,很可能是 auth/kubernetes/config 没配对,vault 无法验证 kube-apiserver 的 tls 证书,或者使用的 kubernetes token 没有权限。vault-agent(sidecar) 报错: service account not authorizedauth/kubernetes/config 中的 role 没有绑定 Pod 使用的 serviceAccount4. vault agent 配置vault-agent 的配置,需要注意的有:如果使用 configmap 提供完整的 config.hcl 配置,注意 agent-initvautl-agent 的 template 说明:目前来说最流行的配置文件格式应该是 json/yaml,以 json 为例,
对每个微服务的 kv 数据,可以考虑将它所有的个性化配置都保存在
2
3
4
5
6
7
8
{
{{ range secrets "
"{{ printf "%s" . }}":
{{ with secret (printf "
{{ .Data.data | toJSONPretty }},
{{ end }}
{{ end }}
}
template 的详细语法参见: https://github.com/hashicorp/consul-template#secret注意:v2 版本的 kv secrets,它的 list 接口有变更,因此在遍历 v2 kv secrets 时,
必须要写成 range secrets "
官方文档完全没提到这一点,我通过 wireshark 抓包调试,对照官方的 KV Secrets Engine - Version 2 (API) 才搞明白这个。这样生成出来的内容将是 json 格式,不过有个不兼容的地方:最后一个 secrets 的末尾有逗号 ,
渲染出的效果示例: 1
2
3
4
5
6
7
8
9
10
{
"secret-a": {
"a": "b",
"c": "d"
},
"secret-b": {
"v": "g",
"r": "c"
},
}
因为存在尾部逗号(trailing comma),直接使用 json 标准库解析它会报错。
那该如何去解析它呢?我在万能的 stackoverflow 上找到了解决方案:yaml 完全兼容 json 语法,并且支持尾部逗号!以 python 为例,直接 yaml.safe_load() 就能完美解析 vault 生成出的 json 内容。5. 拓展:在 kubernetes 中使用 vault 的其他姿势除了使用官方提供的 sidecar 模式进行 secrets 注入,社区也提供了一些别的方案,可以参考:hashicorp/vault-csi-provider: 官方的 Beta 项目,通过 Secrets Store CSI 驱动将 vault secrets 以数据卷的形式挂载到 pod 中kubernetes-external-secrets: 提供 CRD 定义,根据定义将 secret 从 vault 中同步到 kubernetes secrets官方的 sidecar/init-container 模式仍然是最推荐使用的。五、使用 vault 实现 AWS IAM Credentials 的自动轮转待续。。。相关内容FinOps for Kubernetes - 如何拆分 Kubernetes 成本部署一个 Kubernetes 集群Kubernetes 微服务最佳实践如果你觉得这篇文章对你有所帮助,欢迎评论、分享、打赏~
赞赏更新于 2021-01-24
Vault, 云原生, Secrets, 配置, 配置管理返回 | 主页QEMU/KVM 虚拟化环境的搭建与使用
云原生流水线 Argo Workflows 的安装、使用以及个人体验Please enable JavaScript to view the comments powered by Utterances.
由 Hugo 强力驱动 | 托管在 Vercel 上 | 主题 - DoIt2021 - 2024 ryan4yin | CC BY-NC 4.0
云时代的机密管理——Vault(Vault的架构设计) - 知乎
云时代的机密管理——Vault(Vault的架构设计) - 知乎切换模式写文章登录/注册云时代的机密管理——Vault(Vault的架构设计)大可不加冰程序员之前的文章大多是介绍了Vault某些特定的应用场景,本文会结合文档,尝试为读者从一个俯瞰的角度介绍一下Vault的架构设计、组成部分的说明,让读者对Vault有一个更加全面和直观的理解。词汇表Vault是由多个松耦合的部件组成的复杂系统,总体来说它由以下几个部件组成:后端存储(Storage Backend):后端存储负责将密文数据存储到可靠的持久存储上。Vault并不假设后端存储上的数据不会被盗取,而只是假设该存储是持久的、可靠的。Vault只会向后端存储写入加密过的数据。后端存储应在Vault服务启动前被妥善配置。屏障(Barrier):屏障是由加密算法所组成的钢筋混凝土防护工事。所有在Vault服务与后端存储之间流动的数据都会经过屏障处理。屏障确保了Vault写入后端存储的一切数据都是加密的,而从后端存储读取的数据都会经由屏障解密交由Vault服务使用。由于屏障的存在,Vault服务启动后,必须进行“解封”(Unseal)处理,获得与后端存储数据相应的主密钥(Master Key)后才能正常工作。机密引擎(Secret Engine):机密引擎负责管理各种机密数据。比如我们之前介绍的“KV“引擎,就是一种简单的保存静态机密数据的机密引擎。某些机密引擎可提供被查询时动态创建机密的动态机密功能,这使得Vault可以提供细颗粒度权限配置的一次一密的临时机密。例如为运维与开发配置不同的策略,并对应不同的Aws权限,相关人员每次读取相关机密时,由Vault动态创建一组拥有有限有效期和预设Aws权限的Access Key和Secret Key,并确保在有效期过后由Vault在Aws上自动删除该Key。审计设备(Auth Method):审计设备负责管理审计日志。进出Vault的每一个请求和响应都会被记录在预设的审计设备上。该部件为Vault与多种不同的审计日志存储的集成提供了一种简单的方式。认证方式(Auth Method):认证方式被用来认证连接到Vault服务的用户或是应用程序的身份信息。一旦认证通过,认证组件会返回一组当前身份适用的策略信息。Vault接受一个通过认证的用户,并返回一个可供将来使用的客户端Token。举个例子,使用userpass认证方式,用户通过提供用户名与密码来进行认证。如果使用github认证方式,用户通过Github Token来通过Vault的认证。客户端Token(Client Token):一个客户端Token(又称“Vault Token“)类似于网站的绘画Cookie。一旦用户通过认证,Vault返回一个客户端Token。该Token可以被Vault用来识别客户端身份并使用相应的访问控制权限约束客户端权限。该Token通过HTTP Header传递。机密(Secret):机密指的是所有由Vault返回的包含机密信息或者密码学原材料(Cryptographic Material)的信息。并不是所有由Vault返回的信息都是机密,例如系统配置、服务状态信息、策略配置等就不属于机密范畴。机密都有对应的租约(Lease),这代表客户端不可以假设机密可以无限期地被使用。Vault会在租约到期后吊销相关机密,Vault管理员也可以在租约到期之前人工吊销机密。Vault服务与客户端之间的这种契约是至关重要的,它允许实现全自动的机密凭据和策略的改变。服务器(Server):Vault依赖于一个长期运行服务实例的服务器。Vault服务器对外提供了一组API用以与客户端互动,以及管理与各种机密引擎的互动,访问控制权限体系的执行,以及机密租约管理和吊销。服务器的架构设计解除了客户端与机密信息、权限策略的耦合,使得管理员可以轻松实现对审计日志的中央化管控。架构全览可以看到,只有后端存储以及HTTP API两部分位于屏障外部,其余所有部件都位于屏障内部。Vault不信任后端存储,所以只会向后端存储写入加密后的密文数据。当Vault服务启动时,必须配置一个后端存储,使得Vault重启后仍然可以读取到数据。HTTP API同样也必须在Vault服务启动时被启动,才能使得客户端可以与Vault服务交互。当Vault启动后,Vault处于“封印(Sealed)“状态。在执行任意操作之前,首先要对Vault执行“解封(Unseal)“操作。当Vault服务初始化时会生成一个加密密钥,所有写入后端存储的数据都会用该密钥加密。该密钥由一个主密钥(Master Key)保护。默认情况下,Vault使用Shamir算法将主密钥拆分成5份,需要至少3份才能重建主密钥:主密钥拆分的份数以及解封要求的最低份数都可以被配置。我们也可以不使用Shamir算法,直接用主密钥解封。一旦Vault获得了加密密钥,就可以解密后端存储上的数据,服务进入解封状态。一旦解封,Vault就会加载所有审计设备、认证方式以及机密引擎的配置信息。当Vault解封,发往Vault的请求就可以通过HTTP API被转往核心(Core)进行处理。核心管理系统接收到的请求,强制执行访问控制权限,以及确保审计信息的成功写入。当客户端首次与Vault连接,它需要经过身份认证。Vault提供了多种身份认证方式。对人类用户比较友好的有userpass、github等,应用程序可以使用公私钥或是Token认证。一个身份认证请求会经由核心抵达相应的认证方式,由认证方式判定认证是否通过,然后返回一组相关的策略。策略(Policies)是一个命名的访问控制规则,比如说,root策略是一个内建策略,它允许访问任意资源。你可以创建任意多个命名的策略,在相关路径上定义细致的权限控制。Vault采用白名单的模式,意为除非策略明确允许某项操作,否则所有操作都是被禁止的。如果一个用户拥有多个策略,对于某项操作,只要任意策略允许就可以执行。策略由内部的策略存储(Policy Store)存储和管理。这个内部的策略存储通过系统后端(System Backend)控制,挂载路径总是为sys/。一旦身份认证通过,并且身份认证方式返回一组适用的策略,Token存储(Token Store)会生成并管理一个新的客户端Token。该Token会被返回给客户端,用来作为后续操作的认证信息,这很像网站在用户登录后通过发还给用户的Cookie传递会话信息的机制。根据身份认证方式的配置,该客户端Token可能还会关联一个租约。这意味着客户端Token可能需要定期续约来避免过期。一旦身份认证通过,后续请求都要附加客户端Token。客户端Token被用来确认客户端有权加载相关策略。策略被用来验证客户请求的权限。通过验证的请求被路由到相关机密引擎,由机密引擎进行处理。如果机密引擎返回一个机密,核心会将其注册到过期管理器(Expiration Manager)并附加一个租约ID。租约ID可用来续约租约或是吊销相关机密。如果客户端任由租约过期,过期管理器会自动吊销相关机密。核心还负责将请求与响应的日志写入审计中介(Audit Broker),由审计中介负责将日志写入所有预设的审计设备。除了处理客户端发送的请求,核心还会负责特定的后台活动。租约管理是至关重要的,它允许自动吊销过期的客户端Token以及机密信息。另外,Vault使用预写日志(Write Ahead Logging)和回滚管理器处理特定的失败场景。这些是由核心透明地执行的,对用户不可见。发布于 2021-05-07 12:08云计算网络安全DevOps赞同 13添加评论分享喜欢收藏申请
开源密码存储引擎 Vault 的安装与使用-腾讯云开发者社区-腾讯云
存储引擎 Vault 的安装与使用-腾讯云开发者社区-腾讯云用户3147702开源密码存储引擎 Vault 的安装与使用关注作者腾讯云开发者社区文档建议反馈控制台首页学习活动专区工具TVP最新优惠活动文章/答案/技术大牛搜索搜索关闭发布登录/注册首页学习活动专区工具TVP最新优惠活动返回腾讯云官网用户3147702首页学习活动专区工具TVP最新优惠活动返回腾讯云官网社区首页 >专栏 >开源密码存储引擎 Vault 的安装与使用开源密码存储引擎 Vault 的安装与使用用户3147702关注发布于 2022-12-21 17:42:241.8K0发布于 2022-12-21 17:42:24举报文章被收录于专栏:小脑斧科技博客小脑斧科技博客1. 引言vault 是一款 HCP 推出的密钥管理引擎,用来集中存储集群运行过程中所需要的秘密信息,例如数据库的访问凭证、密码、密钥等。它保证了存储与通信过程的保密性,这对于我们无处不在的敏感信息的数据安全显然是十分必要的。与此同时,vault 拥有一系列可插拔功能扩展,可以支持将 vault 的实际数据存储到内存、文件系统、google cloud、AWS、etcd 等多种存储介质中,满足不同的集群部署需求,可谓是非常灵活。本文我们就来初步介绍一下 vault 这款存储的搭建和使用。2. Vault 安装在不同的平台上,vault 安装略有不同,可以参考实际的文档:https://www.vaultproject.io/downloads例如在 centos 上,可以通过下面的命令来进行安装: sudo yum install -y yum-utilssudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install vault复制3. 启动 Server3.1 测试环境如果仅用于测试,只需要执行下面的命令即可: vault server -dev复制命令执行后的返回文本中会有 Unseal Key 和 Root Token 两个参数:==> Vault server configuration: Api Address: http://127.0.0.1:8200
Cgo: disabled
Cluster Address: https://127.0.0.1:8201
Listener 1: tcp (addr: "127.0.0.1:8200", cluster address: "127.0.0.1:8201", max_request_duration: "1m30s", max_request_size: "33554432", tls: "disabled")
Log Level: info
Mlock: supported: false, enabled: false
Recovery Mode: false
Storage: inmem
Version: Vault v1.4.1复制WARNING! dev mode is enabled! In this mode, Vault runs entirely in-memoryand starts unsealed with a single unseal key. The root token is alreadyauthenticated to the CLI, so you can immediately begin using Vault.You may need to set the following environment variable: $ export VAULT_ADDR='http://127.0.0.1:8200'The unseal key and root token are displayed below in case you want toseal/unseal the Vault or re-authenticate.Unseal Key: 1+yv+v5mz+aSCK67X6slL3ECxb4UDL8ujWZU/ONBpn0Root Token: s.XmpNPoi9sRhYtdKHaQhkHP6xDevelopment mode should NOT be used in production installations!==> Vault server started! Log data will stream in below:接下来,按照上述指引,需要 export 两个环境变量: export VAULT_ADDR='http://127.0.0.1:8200'
export VAULT_TOKEN="s.XmpNPoi9sRhYtdKHaQhkHP6x"复制通过 vault status 命令可以查看 vault 状态: $ vault status
Key Value
--- -----
Seal Type shamir
Initialized true
Sealed false
Total Shares 1
Threshold 1
Version 1.7.0
Storage Type inmem
Cluster Name vault-cluster-4d862b44
Cluster ID 92143a5a-0566-be89-f229-5a9f9c47fb1a
HA Enabled false复制3.2 正式环境3.2.1 启动 server上述测试环境部署的 vault 使用了用于测试的一系列默认配置,如果我们要用于正式环境,我们自然需要进行一系列必要的配置,例如 vault 的数据具体存储在哪里,http 端口与 tls 协议支持等。vault 支持通过 json、linux config、hcl 等多种配置方式,例如下面这个 config.hcl 配置: storage "raft" {
path = "./vault/data"
node_id = "node1"
}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = "true"
}
api_addr = "http://127.0.0.1:8200"
cluster_addr = "https://127.0.0.1:8201"
ui = true复制接下来就可以启动 server 了: mkdir -p ./vault/data
vault server -config=config.hcl复制3.2.2 server 的初始化对于单机模式的 server 来说,每个 server 都需要进行一次且只能进行一次初始化操作,用来应用上述配置。对于 HA 模式的 vault 来说,则每个 cluster 需要执行一次初始化操作。执行下面的命令对 vault 进行初始化操作: export VAULT_ADDR='http://127.0.0.1:8200'
vault operator init复制会打印出下列信息:Unseal Key 1: 4jYbl2CBIv6SpkKj6Hos9iD32k5RfGkLzlosrrq/JgOmUnseal Key 2: B05G1DRtfYckFV5BbdBvXq0wkK5HFqB9g2jcDmNfTQiSUnseal Key 3: Arig0N9rN9ezkTRo7qTB7gsIZDaonOcc53EHo83F5chAUnseal Key 4: 0cZE0C/gEk3YHaKjIWxhyyfs8REhqkRW/CSXTnmTilv+Unseal Key 5: fYhZOseRgzxmJCmIqUdxEm9C3jB5Q27AowER9w4FC2Ck
Initial Root Token: s.KkNJYWF5g0pomcCLEmDdOVCW
Vault initialized with 5 key shares and a key threshold of 3. Please securelydistribute the key shares printed above. When the Vault is re-sealed,restarted, or stopped, you must supply at least 3 of these keys to unseal itbefore it can start servicing requests.
Vault does not store the generated root key (previously known as master key).Without at least 3 key to reconstruct the root key, Vault will remainpermanently sealed!
It is possible to generate new unseal keys, provided you have a quorum ofexisting unseal keys shares. See "vault operator rekey" for more information.3.2.3 对 key 解封初始化后,vault 还不知道如何使用具体的存储,因此处于封锁状态,在上面的 output 内容中有这样一句话:Vault initialized with 5 key shares and a key threshold of 3.说明 threshold 为 3,也就是说,我们至少要对 3 个 key 执行解封操作后,server 才可以使用。执行下面的命令即可: vault operator unseal
secret/data/hello
======= Metadata =======
Key Value
--- -----
created_time 2022-01-15T01:40:09.888293Z
custom_metadata
deletion_time n/a
destroyed false
version 2
===== Data =====
Key Value
--- -----
excited yes
foo world复制我们也可以指定 path 下具体的 field 来获取某个值: vault kv get -mount=secret -field=excited hello复制这样就会直接打印出值:yes4.3 删除数据把上述查询语句中的 get 关键字改成 delete 关键字就可以删除对应数据: vault kv delete -mount=secret -field=excited hello复制但是,如果你是误删除的话,vault 是支持误删恢复的,前提是你需要将 destroyed 配置为 false。通过下面的命令,可以将已删除数据进行恢复: vault kv undelete -mount=secret -versions=2 hello复制本文参与 腾讯云自媒体分享计划,分享自微信公众号。原始发表:2022-09-03,如有侵权请联系 cloudcommunity@tencent.com 删除存储本文分享自 小脑斧科技博客 微信公众号,前往查看如有侵权,请联系 cloudcommunity@tencent.com 删除。本文参与 腾讯云自媒体分享计划 ,欢迎热爱写作的你一起参与!存储评论登录后参与评论0 条评论热度最新登录 后参与评论推荐阅读LV.关注文章0获赞0目录1. 引言2. Vault 安装3. 启动 Server3.1 测试环境3.2 正式环境3.2.1 启动 server3.2.2 server 的初始化3.2.3 对 key 解封3.2.4 创建 engine4. vault 的基本使用4.1 数据写入4.2 数据读取4.3 删除数据相关产品与服务对象存储对象存储(Cloud Object Storage,COS)是由腾讯云推出的无目录层次结构、无数据格式限制,可容纳海量数据且支持 HTTP/HTTPS 协议访问的分布式存储服务。腾讯云 COS 的存储桶空间无容量上限,无需分区管理,适用于 CDN 数据分发、数据万象处理或大数据计算与分析的数据湖等多种场景。免费体验产品介绍产品文档COS新用户专享存储包低至1元,新老同享存储容量低至0.02元/GB/月,立即选购!
领券社区专栏文章阅读清单互动问答技术沙龙技术视频团队主页腾讯云TI平台活动自媒体分享计划邀请作者入驻自荐上首页技术竞赛资源技术周刊社区标签开发者手册开发者实验室关于社区规范免责声明联系我们友情链接腾讯云开发者扫码关注腾讯云开发者领取腾讯云代金券热门产品域名注册云服务器区块链服务消息队列网络加速云数据库域名解析云存储视频直播热门推荐人脸识别腾讯会议企业云CDN加速视频通话图像分析MySQL 数据库SSL 证书语音识别更多推荐数据安全负载均衡短信文字识别云点播商标注册小程序开发网站监控数据迁移Copyright © 2013 - 2024 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有 深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档Copyright © 2013 - 2024 Tencent Cloud.All Rights Reserved. 腾讯云 版权所有登录 后参与评论00