可以创建一个secret_id
基本上永不过期的 Vault AppRole。但是,这应该仅限于在 Vault 开发服务器上使用(不包含任何生产凭据的服务器)以及在开发环境中使用。
话虽如此,这是我根据 Vault 文档中的几篇文章使用的过程,但主要是AppRole Pull Authentication。
这假设 Vaultapprole
身份验证方法已安装在approle/
,并且您已登录到 Vault,在 Vault 服务器上拥有root
或admin
特权,并且拥有有效的、未过期的令牌。
注意:对于为以下字段提供的值,vault
似乎可以接受的最大值是 999,999,999。对于 TTL 字段,这是超过 31 年的秒数。这不是永远的,但更新secret_id
可能会成为其他人的问题(SEP)已经足够长了。
# Vault server address to be used by the Vault CLI.
export VAULT_ADDR="https://vault-dev.example.com:8200/"
# Vault namespace to be used by the CLI.
# Required for Cloud and Enterprise editions
# Not applicable for Open Source edition
export VAULT_NAMESPACE="admin"
# The name of the Vault AppRole
export VAULT_ROLE=my-approle
# Override defaults on the approle authentication method
# NOTE: In this command, the field names, default-lease-ttl
# and max-lease-ttl contain dashes ('-'), NOT
# underscores ('_'), and are preceded by a single
# dash ('-').
vault auth tune \
-default-lease-ttl=999999999 \
-max-lease-ttl=999999999 approle/
# Override defaults on the approle
# NOTE: In this command, the field names, secret_id_ttl and
# secret_id_num contain underscores ('_'), NOT
# dashes ('-'), and are NOT preceded by a single
# dash ('-').
vault write auth/approle/role/my-approle \
secret_id_ttl=999999999 \
secret_id_num_uses=999999999
# Create a new secret_id for the approle which uses the new defaults
vault write -f auth/approle/role/my-approle/secret-id
更新服务器配置文件以使用新的secret_id
,您就可以开始了。