티스토리 뷰
반응형
1. Dev 환경으로 시작하기
- vault server -dev 명령어 입력
ubuntu@ingnoh ~ % vault server -dev
==> Vault server configuration:
Api Address: http://127.0.0.1:8200
Cgo: disabled
Cluster Address: https://127.0.0.1:8201
Go Version: go1.14.4
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: false, enabled: false
Recovery Mode: false
Storage: inmem
Version: Vault v1.4.3
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: [Your_Unseal_Key]
Root Token: [Your_Root_Token]
Development mode should NOT be used in production installations!
==> Vault server started! Log data will stream in below:
- 서버가 실행된 후 Unseal Key와 Root Token이 주어진다.
- 이는 dev 환경에서는 init 과정이 자동으로 이루어지기 때문. 실제로는 별도의 init 과정이 필요하다.
- Unseal Key : Sealed 상태의 Vault를 열기 위해 입력해야할 Key
- Root Token : Vault에 대한 Root 권한을 갖는 Credential
- 때문에 Prod. 환경에서는 Root Token의 사용은 지양하는 것이 좋다.
- dev 환경에서는 1개의 Unseal Key가 주어지며, 항상 Unseal 된 상태를 유지한다.
- 당연히 Prod. 환경에서는 사용하지 않는 것이 좋다.
2. Vault 상태 확인하기
- 새로운 터미널을 열어준다.
- 이후의 실습에 앞서, dev 환경에서는 TLS를 사용하지 않으므로 export VAULT_ADDR=http://127.0.0.1:8200을 입력해준다.
- vault status 명령어를 입력해보자 :
ubuntu@ingnoh ~ % export VAULT_ADDR=http://127.0.0.1:8200
ubuntu@ingnoh ~ % vault status
Key Value
--- -----
Seal Type shamir
Initialized true
Sealed false
Total Shares 1
Threshold 1
Version 1.4.3
Cluster Name vault-cluster-f27397ec
Cluster ID 7166d0d7-6203-1dee-7559-cc07499825af
HA Enabled false
- Initialized : dev 환경에서는 Vault가 자동으로 초기화된다.
- 실제로는 vault operator init 명령어를 통해 직접 초기화해주어야 한다!
- Sealed : dev 환경에서는 Vault가 기본적으로 Unsealed 되어 있다.
- Total Shares : Vault의 Unsealing에 사용하기 위해 자동으로 생성한 Unseal Key의 개수를 말한다.
- 예를 들어, Total Shares 값이 5인 경우 Vault의 Unsealing에 사용할 수 있는 Key가 다섯 개 생성된다.
- Threshold : Vault의 Unsealing에 필요한 Unseal Key 개수를 말한다.
- 예를 들어, Total Shares 5 / Threshold 3일 경우 Vault의 Unsealing을 위해 Unseal Key 5개 중 최소 3개가 입력되어야 한다.
- Total Shares와 Threshold 값은 기본적으로 5 / 3으로 설정되며, 최소 1 / 1까지 설정할 수 있다.
- dev 환경에서는 최소값인 1 / 1 설정을 사용한다.
3. Vault UI 접속하기
- Vault의 dev 환경은 기본적으로 UI를 포함한다. dev 환경에서 Vault UI 접속에 사용되는 기본 URL은 http://127.0.0.1:8200이 된다.
- 접속을 위해 dev 서버 구축시 할당 받은 Root Token을 사용하자.
4. Vault에 데이터 저장하기
- dev 환경의 Vault에는 기본적으로 KV Secrets Engine이 활성화되어 있다 :
- 이름에서도 알 수 있듯, Vault에 의해 암호화된 데이터를 K-V Pair 형식으로 Backend Storage에 저장하는 Secrets Engine이다.
ubuntu@ingnoh ~ % vault secrets list
Path Type Accessor Description
---- ---- -------- -----------
cubbyhole/ cubbyhole cubbyhole_88c87fc0 per-token private secret storage
identity/ identity identity_7565c2c3 identity store
secret/ kv kv_d201e798 key/value secret storage
sys/ system system_44749713 system endpoints used for control, policy and debugging
- 세번째 줄로 미루어보아 KV Secrets Engine은 secret/ 경로를 사용하는 것을 알 수 있다.
- 이러한 Path 정보는 Vault에게 Secret을 어떤 Secrets Engine에게 라우팅할지 알려주기 위해 사용한다.
- KV Secrets Engine을 활용하기 위해 다음의 명령어를 사용해보자 :
ubuntu@ingnoh ~ % vault kv put secret/ingnoh code=monkey
Key Value
--- -----
created_time 2020-07-23T07:32:41.471232Z
deletion_time n/a
destroyed false
version 1
- secret/ingnoh 경로에 code / monkey라는 K-V Pair를 저장한다.
- 저장된 데이터는 다음과 같은 명령어를 통해 확인할 수 있다 :
ubuntu@ingnoh ~ % vault kv get secret/ingnoh
====== Metadata ======
Key Value
--- -----
created_time 2020-07-23T07:32:41.471232Z
deletion_time n/a
destroyed false
version 1
==== Data ====
Key Value
--- -----
code monkey
- Vault UI에서도 같은 내용을 확인할 수 있다. secret을 눌러 값이 저장된 것을 확인하자!
- 이렇게 Vault에 작성한 Secret은 스토리지(dev 환경의 경우, In-memory)에 저장되기 전에 암호화된다고 한다.
- 기본적으로, Vault는 Backend Storage를 신뢰하지 않도록 동작하기 때문이라고 함.
- Backend Storage는 Vault의 개입 없이는 복호화된 값을 확인할 방법이 없다.
- 즉, 위의 간단한 예제 이후에 vault operator seal을 통해 Vault를 Sealed 상태로 만들면 저장된 값이 안전하게 보호된다.
'HashiCorp. > vault' 카테고리의 다른 글
[Vault] macOS 기준 버전 업그레이드 (0) | 2022.10.20 |
---|---|
[Vault] Basic (2) | 2020.07.21 |
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- AWS IoT
- eureka
- spring boot
- hashicorp
- RancherDesktop
- AWS
- postgresql
- JEST
- kotlin
- Linux
- Vault
- Puppeteer
- shell
- Java
- Spring Cloud Config
- Database
- IntelliJ
- Node.js
- Gradle
- Docker
- 코딩테스트
- Git
- pgloader
- javascript
- JPA
- mysql
- terraform
- jQuery
- etc
- react
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함