hashicorp,vault,key sharing,secret-engine,한글
hashicorp vault란 무엇인가?
vault 페이지메인을 가면 아래와 같이 이야기가 나온다.
안전하게 저장하는 저장소
라고 이야기한다.몇 가지 특징이 있는데,
centrally store
한곳에서 관리
해준다면? > goodAuthorization, Authentication
권한
과 인증
이 필요하다.ttl
이 있고, 언제든 revoking
할 수 있게 지원해준다.key sharing
key rolling
을 통해 사용자는 특정 주기로 새로운 마스터키를 생성해 사용함으로 보다 안전한 운영이 가능하다.certification issuing
export VAULT_ADDR='[<http://127.0.0.1:8200>](<http://127.0.0.1:8200/>)'
실행, config로 vault client가 server와 통신하기 위해 사용될것임.VAULT_DEV_ROOT_TOKEN_ID
로 저장해둔다.//최종 env 저장형태
env | grep VAULT
VAULT_ADDR=http://127.0.0.1:8200
VAULT_DEV_ROOT_TOKEN_ID=s.bOGKkztDunY9OcTT4js5MPjW
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 status --address="<http://127.0.0.1:8200>"
Key Value
--- -----
Seal Type shamir // key 분배 알고리즘(<https://learn.hashicorp.com/img/vault-shamir-secret-sharing.svg>)
Initialized true
Sealed false
Total Shares 1
Threshold 1
Version 1.3.4
Cluster Name vault-cluster-6258aaba
Cluster ID 8d6af2ac-c0b9-0890-568e-95ae04836997
HA Enabled false
vault kv
로 저장해보자.
vault kv put secret/hello foo=world
// vault kv put secret/hello foo=world
Key Value
--- -----
created_time 2020-04-07T02:26:56.656645Z
deletion_time n/a
destroyed false
version 1
prefix
인 secret이 중요하다. 이 위치가 임의의 secret을 read / write 한다.vault kv put secret/hello foo=world excited=yes
// vault kv put secret/hello foo=world excited=yes
Key Value
--- -----
created_time 2020-04-07T02:29:34.140561Z
deletion_time n/a
destroyed false
version 2
vault kv get secret/hello
// vault kv get secret/hello
====== Metadata ======
Key Value
--- -----
created_time 2020-04-07T02:29:34.140561Z
deletion_time n/a
destroyed false
version 2
===== Data =====
Key Value
--- -----
excited yes
foo world
//vault kv get secret/hello | awk '{print $1}'
======
Key
---
created_time
deletion_time
destroyed
version
=====
Key
---
excited
foo
//vault kv get secret/hello | awk '{print $2}'
Metadata
Value
-----
2020-04-07T02:29:34.140561Z
n/a
false
2
Data
Value
-----
yes
world
lease_id
가 하나의 lease에 고유한 값을 가지고 lease_duration
가 valid 한 시간을 가진다.godres ~/key $ vault kv get -field=excited secret/hello
yes
vault kv delete secret/hello
//vault kv delete secret/hello
Success! Data deleted (if it existed) at: secret/hello
//vault kv get secret/hello
====== Metadata ======
Key Value
--- -----
created_time 2020-04-07T02:29:34.140561Z
deletion_time 2020-04-07T02:39:22.994973Z
destroyed false
version 2
secret/
prefix로 put을 등록했었다. 그렇지 않다면?// vault kv put foo/bar a=b
Error making API request.
URL: GET <http://127.0.0.1:8200/v1/sys/internal/ui/mounts/foo/bar>
Code: 403. Errors:
* preflight capability check returned 403, please ensure client's policies grant access to path "foo/bar/"
isolated
되어있어 서로 path끼리 이야기할 수 없다
.// vault secrets enable -path=kv kv
Success! Enabled the kv secrets engine at: kv/
// vault secrets enable kv
Error enabling: Error making API request.
URL: POST <http://127.0.0.1:8200/v1/sys/mounts/kv>
Code: 400. Errors:
* path is already in use at kv/
vault secrets list
// vault secrets list
Path Type Accessor Description
---- ---- -------- -----------
cubbyhole/ cubbyhole cubbyhole_7bfffbf6 per-token private secret storage
identity/ identity identity_f6977784 identity store
kv/ kv kv_ac183fa7 n/a
secret/ kv kv_e2117b1e key/value secret storage
sys/ system system_21f99e6c system endpoints used for control, policy and debugging
sys/
path는 vault core system에 사용되 뉴비에게는 의미없다.// vault kv put kv/hello target=world
Success! Data written to: kv/hello
// vault kv get kv/hello
===== Data =====
Key Value
--- -----
target world
// vault kv put kv/hello2 target=world
Success! Data written to: kv/hello2
// vault kv list kv/
Keys
----
hello
hello2
vault secrets disable kv/
// vault secrets disable kv/
// vault secrets list
Path Type Accessor Description
---- ---- -------- -----------
cubbyhole/ cubbyhole cubbyhole_7bfffbf6 per-token private secret storage
identity/ identity identity_f6977784 identity store
secret/ kv kv_e2117b1e key/value secret storage
sys/ system system_21f99e6c system endpoints used for control, policy and debugging