ããã¯ããªã«ãããããŠæžãããã®ïŒ
åã ããã¡ãã£ãšæ°ã«ãªã£ãŠãããVaultãæ±ã£ãŠã¿ãããšã«ããŸããã
Vault
Vaultã®ãªãã£ã·ã£ã«ãµã€ãã¯ããã¡ããHashiCorpã®ãããã¯ãã§ããã
Vaultãã©ããªãã®ãã¯ããŠãŒã¹ã±ãŒã¹ãèŠãã®ãè¯ãæ°ãããŸãã
- Secrets Management
- æ©å¯æ å ±ã®ç®¡ç
- Dynamic Secrets
- åçã«ã·ãŒã¯ã¬ãããçæãæå¹æéåãã«ããç Žæ£
- Kubernetes Secrets
- Kubernetesç°å¢ã«ãããæ©å¯æ å ±ç®¡ç
- Database Credential Rotation
- ããŒã¿ããŒã¹ã®ã¯ã¬ãã³ã·ã£ã«ã®ããŒããŒã·ã§ã³ããã³æå¹æé管çã®èªåå
- Automated PKI Infrastructure
- 蚌ææžã®èªåçæ
- Identity-based Access
- ã¯ã©ãŠãçã®IDãããã€ããŒã䜿çšããã¢ã¯ã»ã¹ç®¡ç
- Data Encryption & Tokenization
- ããŒã¿ã®æå·åãšããŒã¯ã³å
- Key Management
- æ§ã ãªKMSãããã€ããŒãããã¯ãšã³ããšããæå·éµã®é åžãã©ã€ããµã€ã¯ã«ç®¡ç
ã ããããé°å²æ°ãæãåããŸããã
ã©ã€ã»ã³ã¹ã¯ãGitHubãªããžããªãèŠããšMozilla Public License 2.0ã§ãã
OSSçãEnterpriseçãCloudçã®3圢æ ã§æäŸãããŠããŸãã
HashiCorp Vault: Enterprise Pricing, Packages & Features
ããã¥ã¡ã³ãããã¥ãŒããªã¢ã«ã¯ãããããã¡ãã
Documentation | Vault by HashiCorp
Vault Tutorials - HashiCorp Learn
ã¯ã©ã€ã¢ã³ãã©ã€ãã©ãªã«ã€ããŠã¯ããã¡ãã«ãŸãšããããŠããŸãã
HTTP API: Libraries | Vault by HashiCorp
Enterpriseçã«ã€ããŠã¯ãããã¥ã¡ã³ãå ã«ç« ãèšããããŠããŸãã
Vault Enterprise | Vault by HashiCorp
èªåãå©çšããã®ã¯OSSçã§ããã
ä»åã¯ãUbuntu Linux 20.04 LTSã«ã€ã³ã¹ããŒã«ããŠãŸãã¯è©ŠããŠã¿ãããšæããŸãã
ç°å¢
ä»åã®ç°å¢ã¯ããã¡ãã
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: foca $ uname -srvmpio Linux 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu Linux 20.04 LTSã§ãã
Vaultãã€ã³ã¹ããŒã«ãã
Vaultãã€ã³ã¹ããŒã«ããæ¹æ³ã¯ãã¡ãã«æžãããŠããŸããã
Install Vault | Vault by HashiCorp
ä»åã¯ãã«ãæžã¿ã®Linuxããã±ãŒãžã䜿ããŸãã
Downloads | Vault by HashiCorp
$ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - $ sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" $ sudo apt-get update $ sudo apt-get install vault
Vault 1.9.1ãã€ã³ã¹ããŒã«ãããŸããã
$ vault version Vault v1.9.1
ã€ã³ã¹ããŒã«ããããã¡ã€ã«ã¯ãããã ãã§ãããsystemdã®ãµãŒãã¹ãŠããããã¡ã€ã«ããããããªãã§ããã
$ dpkg -L vault /usr /usr/bin /usr/bin/vault /etc /etc/vault.d /etc/vault.d/vault.env /etc/vault.d/vault.hcl /usr/lib /usr/lib/systemd /usr/lib/systemd/system /usr/lib/systemd/system/vault.service
ãã«ãã
$ vault -h Usage: vault <command> [args] Common commands: read Read data and retrieves secrets write Write data, configuration, and secrets delete Delete secrets and configuration list List data or secrets login Authenticate locally agent Start a Vault agent server Start a Vault server status Print seal and HA status unwrap Unwrap a wrapped secret Other commands: audit Interact with audit devices auth Interact with auth methods debug Runs the debug command kv Interact with Vault's Key-Value storage lease Interact with leases monitor Stream log messages from a Vault server namespace Interact with namespaces operator Perform operator-specific tasks path-help Retrieve API help for paths plugin Interact with Vault plugins and catalog policy Interact with policies print Prints runtime configurations secrets Interact with secrets engines ssh Initiate an SSH session token Interact with tokens
ã³ãã³ãããšã®ãªãã·ã§ã³ã¯ã-h
ãä»ããŠå®è¡ããã°ç¢ºèªã§ãããã§ãã
$ vault server -h Usage: vault server [options] This command starts a Vault server that responds to API requests. By default, Vault will start in a "sealed" state. The Vault cluster must be initialized before use, usually by the "vault operator init" command. Each Vault server must also be unsealed using the "vault operator unseal" command or the API before the server can respond to requests. Start a server with a configuration file: $ vault server -config=/etc/vault/config.hcl Run in "dev" mode: $ vault server -dev -dev-root-token-id="root" For a full list of examples, please see the documentation. HTTP Options: -address=<string> Address of the Vault server. The default is https://127.0.0.1:8200. This can also be specified via the VAULT_ADDR environment variable. ãçç¥ã
åã³ãã³ãã«å¯Ÿããããã¥ã¡ã³ãã¯ããã¡ãã
Commands (CLI) | Vault by HashiCorp
éçºã¢ãŒãã®ãµãŒããŒãèµ·åãã
ãã¥ãŒããªã¢ã«ãèŠããšããŸãã¯ãµãŒããŒãèµ·åããããã§ãã
Starting the Server | Vault - HashiCorp Learn
éçºã¢ãŒãã®ãµãŒããŒãè©ŠããŠã¿ãŸãããããšã
éçºã¢ãŒãã®ãµãŒããŒãšã¯ããããããã®ã¿ããã§ãã
-dev
ãªãã·ã§ã³ãã€ããŠèµ·åãã- ããŒã«ã«éçºããã¹ãã調æ»ç®çã«äœ¿çšãã
- ã»ãã¥ã¢ã§ã¯ãªããä¿è·ãããŠããªã
- ããŒã¿ã¯ã¡ã¢ãªäžã«ä¿åããã
- ãããã¯ã·ã§ã³ç°å¢ã§äœ¿çšããŠã¯ãªããªã
確ãã«"éçºã¢ãŒã"ã§ããã
server - Command | Vault by HashiCorp
éçºã¢ãŒãã®ãµãŒããŒã¯èšå®æžã¿ã®ãã®ã«ãªãããã§ãããã§ã¯ãªãå Žåã¯èšå®ãã¡ã€ã«ã§Vaultã®èšå®ãè¡ããŸãã
Server Configuration | Vault by HashiCorp
ãã¡ãã«ã€ããŠã¯ããŸãå¥ã®æ©äŒã«ã
ã§ã¯ãéçºãµãŒããŒãèµ·åããŠã¿ãŸãã
$ vault server -dev
èµ·åãããšãVaultèªèº«ã®æ å ±ã衚瀺ãã
==> Vault server configuration: Api Address: http://127.0.0.1:8200 Cgo: disabled Cluster Address: https://127.0.0.1:8201 Go Version: go1.17.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: true, enabled: false Recovery Mode: false Storage: inmem Version: Vault v1.9.1 ==> Vault server started! Log data will stream in below:
æåŸã«ãããªæ å ±ã衚瀺ãããŸãã
2021-12-21T00:03:02.566+0900 [INFO] expiration: lease restore complete 2021-12-21T00:03:02.566+0900 [INFO] core: post-unseal setup complete 2021-12-21T00:03:02.566+0900 [INFO] core: vault is unsealed 2021-12-21T00:03:02.569+0900 [INFO] core: successful mount: namespace="\"\"" path=secret/ type=kv 2021-12-21T00:03:02.578+0900 [INFO] secrets.kv.kv_27c06bad: collecting keys to upgrade 2021-12-21T00:03:02.579+0900 [INFO] secrets.kv.kv_27c06bad: done collecting keys: num_keys=1 2021-12-21T00:03:02.579+0900 [INFO] secrets.kv.kv_27c06bad: upgrading keys finished 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 variable: $ 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: [Unseal Key] Root Token: [Root Token] Development mode should NOT be used in production installations!
Unseal KeyãšRoot Tokenã衚瀺ãããŠããŸãããããããVAULT_ADDR
ãšããç°å¢å€æ°ã«ã€ããŠãæžãããŠããŸããã
å¥ã®ã¿ãŒããã«ããã¢ã¯ã»ã¹ããŠã¿ãŸãããã
ãã®ãŸãŸã ãšã¢ã¯ã»ã¹ã§ããŸããã
$ vault status Error checking seal status: Get "https://127.0.0.1:8200/v1/sys/seal-status": http: server gave HTTP response to HTTPS client
éçºãµãŒããŒèµ·åæã«æ瀺ãããŠãããšãããVAULT_ADDR
ç°å¢å€æ°ãèšå®ããŠã¿ãŸãã
$ export VAULT_ADDR=http://127.0.0.1:8200
ä»åºŠã¯ã¢ã¯ã»ã¹ã§ããŸããã
$ vault status Key Value --- ----- Seal Type shamir Initialized true Sealed false Total Shares 1 Threshold 1 Version 1.9.1 Storage Type inmem Cluster Name vault-cluster-5df6d588 Cluster ID f82dde5c-7ecc-5e71-d7ba-f7b51c72f17e HA Enabled false
vault status
ã¯ãçŸåšã®Vaultã®ç¶æ
ãåºåããã³ãã³ãã§ãã
status - Command | Vault by HashiCorp
autocompletionãæå¹ã«ãã
å
ã«é²ãåã«ãvault
ã³ãã³ãã®autocompletionãæå¹ã«ããŠãããŸãããã
Vault Commands (CLI) / Autocompletion
以äžã®ã³ãã³ããå®è¡ã
$ vault -autocomplete-install
$HOME/.bashrc
ãã¡ã€ã«ã«ã以äžãè¿œå ãããããã§ãã
complete -C /usr/bin/vault vault
æ°ããèµ·åããã·ã§ã«ãããautocompletionãæå¹ã«ãªããŸãã
ã·ãŒã¯ã¬ãããç»é²ãã
ç¶ããŠãã·ãŒã¯ã¬ãããç»é²ããŠã¿ãŸãããã
Your First Secret | Vault - HashiCorp Learn
ã³ãã³ããšããŠã¯ãvault kv
ã䜿ãããã§ãã
kv - Command | Vault by HashiCorp
kv
ãšã¯ãVaultã®Key Value Secrets Engineãæäœããã³ãã³ãã§ãã
KV - Secrets Engines | Vault by HashiCorp
KV Secrets Engineã«ã¯ããŒãžã§ã³ã2ã€ãããéçºãµãŒããŒã§ã¯ããŒãžã§ã³2ããééçºãµãŒããŒã§ã¯ããŒãžã§ã³1ã
ããã©ã«ãã§äœ¿ãããããã§ãã
Additionally, when running a dev-mode server, the v2 kv secrets engine is enabled by default at the path secret/ (for non-dev servers, it is currently v1).
KV - Secrets Engines | Vault by HashiCorp
ã¢ã¯ã»ã¹ãããã¹ãããããéãããã§ãããããŒãžã§ã³1ãš2ã®éãã¯ãã¡ã¿ããŒã¿ãå±¥æŽã®ç®¡çã®ããã§ãã
ããŒãžã§ã³2ã ãšãã¡ã¿ããŒã¿ã®ä¿åãå±¥æŽç®¡çãè¡ãããŸãã
ã§ã¯ããã¹secret/my-creds
ã«kv put
ã§ããŒã¿ãæžã蟌ãã§ã¿ãŸããããŒã¿ã¯key=value
圢åŒã§æå®ããããã§ãã
$ vault kv put secret/my-creds hello=world
ã³ãã³ãã®ã¬ã¹ãã³ã¹ã¯ããã®ããã«ãªããŸãã
Key Value --- ----- created_time 2021-12-20T16:40:13.178757588Z custom_metadata <nil> deletion_time n/a destroyed false version 1
ç»é²ããããŒã¿ã¯ãkv list
ã§æå®ãããã¹ã§ããŒã衚瀺ã§ããŸãã
$ vault kv list secret Keys ---- my-creds
ããŒã¿ãååŸããã«ã¯ãkv get
ã§ãã
$ vault kv get secret/my-creds ======= Metadata ======= Key Value --- ----- created_time 2021-12-20T16:40:13.178757588Z custom_metadata <nil> deletion_time n/a destroyed false version 1 ==== Data ==== Key Value --- ----- hello world
kv put
ã§ãåæã«è€æ°ã®ããŒã¿ãæžã蟌ãããšãã§ããŸãã
$ vault kv put secret/my-creds foo=bar var=val Key Value --- ----- created_time 2021-12-20T16:44:02.067907299Z custom_metadata <nil> deletion_time n/a destroyed false version 2
ããŒã¿ãååŸããŠç¢ºèªã
$ vault kv get secret/my-creds ======= Metadata ======= Key Value --- ----- created_time 2021-12-20T16:44:02.067907299Z custom_metadata <nil> deletion_time n/a destroyed false version 2 === Data === Key Value --- ----- foo bar var val
ããã§æ°ã¥ãã®ã§ãããkey=value
圢åŒã§æå®ããŠãããããšãã£ãŠããããŒãéè€ããªãã£ããè¿œå ããšããããã§ã¯
ãªããã§ããã
å¥ã®ãã¹ã«ãè¿œå ããŠã¿ãŸãããã
$ vault kv put secret/test-creds name=vault $ vault kv put secret/my-creds/sub name=terraform $ vault kv put secret/sub1/sub2/sub3 hello=world
kv list
ã§ç¢ºèªã
$ vault kv list secret Keys ---- my-creds my-creds/ sub1/ test-creds
ãµããã¹ã確èªã
$ vault kv list secret/my-creds Keys ---- sub
Secrets Engine
Secrets Engineã¯ãããŒã¿ãä¿åãçæããããŠæå·åããã³ã³ããŒãã³ãã§ãã
Secrets Engines | Vault - HashiCorp Learn
secrets - Command | Vault by HashiCorp
Secrets Engines | Vault by HashiCorp
Secrets Engineã¯å€æ°ãããããŒã¿ããŒã¹ãConsulãªã©ã®ããŒã¿ã¹ãã¢ãAWSãAzureãªã©ã®ã¯ã©ãŠããªã©ããããŸãã
Secrets Engineã¯ãã¹ã«å¯ŸããŠæå¹åããç¡å¹åã移åãã§ããŸãã
ããã§ãvault secrets list
ãšããã³ãã³ããå®è¡ããŠã¿ãŸãã
$ vault secrets list Path Type Accessor Description ---- ---- -------- ----------- cubbyhole/ cubbyhole cubbyhole_491c1d0f per-token private secret storage identity/ identity identity_2f41def3 identity store secret/ kv kv_53b92a41 key/value secret storage sys/ system system_faffd04e system endpoints used for control, policy and debugging
å
ã»ã©ãŸã§äœ¿ã£ãŠããsecret/
ãšãããã¹ããkvãšããTypeã«ãªã£ãŠããŸãã
ã€ãŸããKeyïŒValue Secrets Engineããã¹secret
ã«å¯ŸããŠæå¹åãããŠããŠãvault kv
ãšããã³ãã³ãã¯
KeyïŒValue Secrets Engineãæ±ãã³ãã³ãã ã£ãããšãããããŸãã
KV - Secrets Engines | Vault by HashiCorp
ããã§ãããã«KeyïŒValue Secrets Engineãæå¹ã«ããŠã¿ãŸããããvault secrets enable [Secrets Engineå]
ã§
æå¹åããŸãã
$ vault secrets enable kv
ããã©ã«ãã§ã¯Secrets Engineã®ååãšãã¹ãåãã«ãªãããã§ããã
$ vault secrets list Path Type Accessor Description ---- ---- -------- ----------- cubbyhole/ cubbyhole cubbyhole_491c1d0f per-token private secret storage identity/ identity identity_2f41def3 identity store kv/ kv kv_f9c9511c n/a secret/ kv kv_53b92a41 key/value secret storage sys/ system system_faffd04e system endpoints used for control, policy and debuggin
-path
ãªãã·ã§ã³ã䜿çšããããšã§ããã¹ãæå®ããããšãã§ããŸãã
$ vault secrets enable -path=key-value kv Success! Enabled the kv secrets engine at: key-value/ $ vault secrets list Path Type Accessor Description ---- ---- -------- ----------- cubbyhole/ cubbyhole cubbyhole_491c1d0f per-token private secret storage identity/ identity identity_2f41def3 identity store key-value/ kv kv_4027def6 n/a kv/ kv kv_f9c9511c n/a secret/ kv kv_53b92a41 key/value secret storage sys/ system system_faffd04e system endpoints used for control, policy and debugging
æå¹åãããã¹ã«ã¯ãsecret
ã®æãšåãããã«æäœãã§ããŸãã
$ vault kv put kv/p1 key1=value1 Success! Data written to: kv/p1 $ vault kv get kv/p1 ==== Data ==== Key Value --- ----- key1 value1
ãªã®ã§ãããããèŠããšããŒã¿ãå°ãªãã§ãããããã¯KeyïŒValue Secrets Engineã®ããŒãžã§ã³1ã䜿ã£ãããã®ããã§ãã
ããŒãžã§ã³2ã䜿ãå Žåã¯ã以äžã®ã©ã¡ããã§æå®ããŸãã
$ vault secrets enable kv-v2 $ vault secrets enable -version=2 kv
ä»åã¯kv-v2
ã§æå®ããŠã¿ãŸãã
$ vault secrets enable kv-v2 Success! Enabled the kv-v2 secrets engine at: kv-v2/ $ vault kv put kv-v2/p1 key1=value1 Key Value --- ----- created_time 2021-12-21T16:37:49.90898581Z custom_metadata <nil> deletion_time n/a destroyed false version 1 $ vault kv get kv-v2/p1 ======= Metadata ======= Key Value --- ----- created_time 2021-12-21T16:37:49.90898581Z custom_metadata <nil> deletion_time n/a destroyed false version 1 ==== Data ==== Key Value --- ----- key1 value1
æåã«äœ¿ã£ãvault kv
ã§ã®æäœãšåãã«ãªããŸããããããŒãžã§ã³1ãš2ã®å·®ãèŠã圢ã«ãªããŸããã
ããã«ããŠããvault secrets list
ã§èŠãŠãäž¡è
ã®åºå¥ã¯ã§ããªãã®ã§ãããã©ãããããããã§ããããïŒ
$ vault secrets list Path Type Accessor Description ---- ---- -------- ----------- cubbyhole/ cubbyhole cubbyhole_491c1d0f per-token private secret storage identity/ identity identity_2f41def3 identity store key-value/ kv kv_4027def6 n/a kv-v2/ kv kv_27428a78 n/a kv/ kv kv_f9c9511c n/a secret/ kv kv_53b92a41 key/value secret storage sys/ system system_faffd04e system endpoints used for control, policy and debugging
ä»ã®Secrets Engineã«ç®ãåãããšãæå¹åããããšã¯vault write
ãvault read
ã§ããŒã¿ã®èªã¿æžããè¡ãããã§ãã
MySQL/MariaDB - Database - Secrets Engines | Vault by HashiCorp
write - Command | Vault by HashiCorp
read - Command | Vault by HashiCorp
ãã¡ãã«ã€ããŠã¯ãå¥ã®æ©äŒã«è©ŠããŠã¿ãŸãããã
Web UIã䜿ã
Vaultã«ã¯Web UIããããéçºãµãŒããŒã§ã¯æå¹ã«ãªã£ãŠããŸãã
Web UI | Vault - HashiCorp Learn
http://localhost:8200
ãŸãã¯http://localhost:8200/ui
ã«ã¢ã¯ã»ã¹ãããšããã°ã€ã³ç»é¢ãçŸããŸãã
ãã®ããŒãžã§ã¯Method
ã¯Token
ã®ãŸãŸã«ããŠãéçºãµãŒããŒèµ·åæã«è¡šç€ºãããŠããRoot Token
ã®å€ãToken
ã«
å
¥åããŸãã
Root Token: [Root Token]
ãã°ã€ã³ãããšãSecrets Engineã®ãªã¹ããèŠãããšãã§ããŸãã
ç»é²ããããŒã¿ãèŠãããšãã§ããããã§ãã
ãŸãšã
VaultããŸãã¯è©ŠããŠã¿ãŸããã
觊ã£ãã°ããã§æ©èœãããããã£ãŠããŸããããããããå°ããã€æ £ããŠãããããªãšæããŸãã