login
?命令使用提供的参数向 Vault 验证用户或机器。身份验证成功会返回一个 Vault 令牌 - 在概念上类似于网站上的会话令牌。默认情况下,此令牌会被缓存在本地以供将来发起请求时使用。
-method
?标志允许使用其他身份验证方法,例如?userpass
、github
?或?cert
。使用这些验证方法时可能需要添加额外的键值对。有关可用于给定身份验证方法的配置参数列表的更多信息,请使用?vault auth help TYPE
?命令获取。您还可以使用?vault auth list
?命令查看已启用的身份验证方法列表。
如果在非默认路径上启用了身份验证方法,则仍然使用?-method
?标志指定验证方法类型,同时使用?-path
?标志指定启用的路径。
如果身份验证请求启用了响应封装(通过?-wrap-ttl
?标志),返回的令牌会自动解封,除非:
-token-only
?标志,这样的话命令只会输出封装令牌。-no-store
?标志,这样的话命令会输出封装令牌的详细信息。login
?默认使用?token
?身份验证方法。其他方式参考:login · 《Vault 中文手册》
$ vault login
Token (will be hidden):
WARNING! The VAULT_TOKEN environment variable is set! The value of this
variable will take precedence; if this is unwanted please unset VAULT_TOKEN or
update its value accordingly.
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 hvs.gWGPZU3tEqUCetkNZVDIDUOt
token_accessor 8A3unHHaMm8VH2Vao2JtkZRk
token_duration ∞
token_renewable false
token_policies ["root"]
identity_policies []
policies ["root"]
$ vault login hvs.gWGPZU3tEqUCetkNZVDIDUOt
WARNING! The VAULT_TOKEN environment variable is set! The value of this
variable will take precedence; if this is unwanted please unset VAULT_TOKEN or
update its value accordingly.
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 hvs.gWGPZU3tEqUCetkNZVDIDUOt
token_accessor 8A3unHHaMm8VH2Vao2JtkZRk
token_duration ∞
token_renewable false
token_policies ["root"]
identity_policies []
policies ["root"]
auth
?命令有一组子命令于和 Vault 的身份验证方法进行交互。用户可以列出、启用、禁用身份验证方法,或是获取相关身份验证方法的帮助信息。
要以用户或计算机身份向 Vault 进行身份验证,请改用?vault login
?命令。此命令用于与身份验证方法本身进行交互,而不是向 Vault 进行身份验证。
auth list
auth list
?命令列出已启用的身份验证方法。
$ vault auth list
Path Type Accessor Description Version
---- ---- -------- ----------- -------
token/ token auth_token_dc03cce5 token based credentials n/a
$ vault auth list -detailed
Path Plugin Accessor Default TTL Max TTL Token Type Replication Seal Wrap External Entropy Access Options Description UUID Version Running Version Running SHA256 Deprecation Status
---- ------ -------- ----------- ------- ---------- ----------- --------- ----------------------- ------- ----------- ---- ------- --------------- -------------- ------------------
token/ token auth_token_dc03cce5 system system default-service replicated false false map[] token based credentials a5d6738e-32bd-d6c0-d278-16572ff8a61a n/a v1.15.4+builtin.vault n/a n/a
delete
?命令从 Vault 中删除指定路径上的机密和配置。删除操作的具体实现是委托给具体路径上挂载的后端实现的。
$ vault delete secret/my-secret
$ vault delete transit/keys/my-key
$ vault delete aws/roles/ops
$ vault read sys/internal/counters/tokens
Key Value
--- -----
counters map[service_tokens:map[total:1]]
$ vault read sys/auth/token/tune
Key Value
--- -----
default_lease_ttl 768h
description token based credentials
force_no_cache false
max_lease_ttl 768h
token_type default-service
token TTL和Max TTL区别:
token若支持续签,则续签的时间最大允许超过max ttl。若超过则无法继续续签