Vault/Install
Vault是一套由HashiCorp开发的密码管理软件。
概要
Vault可以拿来存放各类credential资料,像是Key或是Password。
安装
Vault是单执行档,建议安装的路径是/usr/local/bin/vault
,这点没有在官方的文件里提到,但官方的范例常使用这个路径[1]。
以Linux版的例子来说:
cd /tmp; wget -c https://releases.hashicorp.com/vault/1.4.3/vault_1.4.3_linux_amd64.zip; unzip vault_1.4.3_linux_amd64.zip; sudo cp vault /usr/local/bin/vault; sudo chmod 755 /usr/local/bin/vault
设定
这边是设定成:
- 使用AWS KMS加解密。
- 使用Amazon DynamoDB当作储存空间。
AWS
DynamoDB
建立一个表格(这边叫vault
),依照官方的设计:
- Primary partition key设为
Path
(string)。 - Primary sort key设为
Key
(string)。
量很少时可以考虑使用on-demand模式按照读写的量计费,而非以保证读写的容量计费。
KMS
使用SYMMETRIC_DEFAULT
建立即可。
IAM
建立使用者并且产生对应的AWS key(access_key
与secret_key
)。
接着挂入对应的Inline Policy Policy-Vault-DynamoDB
,需要修改账户编号(这边是123456789012
)与DynamoDB的表格名称部分(这边是vault
):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"dynamodb:BatchGetItem",
"dynamodb:BatchWriteItem",
"dynamodb:PutItem",
"dynamodb:DescribeTable",
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:Scan",
"dynamodb:ListTagsOfResource",
"dynamodb:Query",
"dynamodb:UpdateItem",
"dynamodb:DescribeTimeToLive",
"dynamodb:GetRecords"
],
"Resource": [
"arn:aws:dynamodb:ap-southeast-1:123456789012:table/vault/stream/*",
"arn:aws:dynamodb:ap-southeast-1:123456789012:table/vault/index/*",
"arn:aws:dynamodb:ap-southeast-1:123456789012:table/vault"
]
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"dynamodb:DescribeReservedCapacityOfferings",
"dynamodb:ListTables",
"dynamodb:DescribeReservedCapacity",
"dynamodb:DescribeLimits"
],
"Resource": "*"
}
]
}
以及Policy-Vault-KMS
,需要修改账户编号(这边是123456789012
)与KMS的Key ID部分(UUID格式,这边是01234567-89ab-cdef-0123-456789abcdef
):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"kms:Encrypt",
"kms:DescribeKey"
],
"Resource": "arn:aws:kms:ap-southeast-1:123456789012:key/01234567-89ab-cdef-0123-456789abcdef"
}
]
}
/etc/vault.d/vault.hcl
Vault的设定档建议的路径是/etc/vault.d/vault.hcl
,这点没有在官方的文件里提到,但官方的范例常使用这个路径[1]。需要修改自己的网络位置(这边使用10.10.10.10
)。
api_addr = "http://10.10.10.10:8200"
cluster_addr = "http://10.10.10.10:8201"
log_level = "Info"
listener "tcp" {
address = "0.0.0.0:8200"
cluster_address = "10.10.10.10:8201"
tls_disable = "true"
}
seal "awskms" {
region = "ap-southeast-1"
access_key = "x"
secret_key = "x"
kms_key_id = "x"
}
storage "dynamodb" {
ha_enabled = "true"
region = "ap-southeast-1"
table = "vault"
access_key = "x"
secret_key = "x"
}
初始化
第一次执行时需要初始化:
vault operator init -recovery-shares=1 -recovery-threshold=1 -address=http://10.10.10.10:8200
参考文献
- ↑ 1.0 1.1 Vault Deployment Guide. [2020-07-15] (English).
外部链接
- 官方网站 (英文)