`login` — Vault에 로그인(인증)하기
login — Vault에 로그인(인증)하기
vault login은 주어진 인자로 사용자나 머신을 Vault에 인증하는 명령어예요. 인증에 성공하면 Vault 토큰이 발급되는데, 개념적으로는 웹사이트의 세션 토큰과 비슷해요. 기본적으로 이 토큰은 이후 요청을 위해 로컬 머신에 캐시돼요.
-method 플래그로 userpass, github, cert 같은 다른 인증 방식을 사용할 수 있어요. 그런 경우 추가로 K=V 쌍이 필요할 수 있어요. 특정 인증 방식에서 사용 가능한 설정 파라미터 목록은 vault auth help TYPE 명령어로 확인할 수 있고, 활성화된 인증 방식 목록은 vault auth list로 볼 수 있어요.
인증 방식이 비표준 경로에 활성화되어 있어도 -method 플래그는 항상 정식 타입(canonical type)을 가리켜요. 다만 -path 플래그는 실제 활성화된 경로를 가리켜요.
응답 래핑(response wrapping)과 함께 인증을 요청했다면(-wrap-ttl), 다음 경우를 제외하고는 반환된 토큰이 자동으로 언랩(unwrap)돼요:
-token-only플래그를 사용한 경우 — 이때는 래핑 토큰(wrapping token)을 출력해요.-no-store플래그를 사용한 경우 — 이때는 래핑 토큰의 상세 정보를 출력해요.
출처: 문서
본문
예시 (Examples)
기본적으로 login은 token 방식을 사용하며 표준 입력에서 토큰을 읽어요:
$ vault login
Token (will be hidden):
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 s.nDj4BB2tK8NaFffwBZBxyIa1
token_accessor ZuaObqdTeCHZ4oa9HWmdQJuZ
token_duration ∞
token_renewable false
token_policies ["root"]
identity_policies []
policies ["root"]
토큰을 명령줄 인자로 직접 넘길 수도 있어요(단, 셸 히스토리나 프로세스 목록에 노출될 수 있음을 유의하세요):
$ vault login s.3jnbMAKl1i4YS3QoKdbHzGXq
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 s.3jnbMAKl1i4YS3QoKdbHzGXq
token_accessor 7Uod1Rm0ejUAz77Oh7SxpAM0
token_duration 767h59m49s
token_renewable true
token_policies ["admin" "default"]
identity_policies []
policies ["admin" "default"]
다른 방식으로 로그인하려면 -method를 사용해요:
$ vault login -method=userpass username=my-username
Password (will be hidden):
Success! You are now authenticated. The token information below is already
stored in the token helper. You do NOT need to run "vault login" again. Future
requests will use this token automatically.
Key Value
--- -----
token s.2y4SU3Sk46dK3p2Y8q2jSBwL
token_accessor 8J125x9SZyB76MI9uF2jSJZf
token_duration 768h
token_renewable true
token_policies ["default"]
identity_policies []
policies ["default"]
token_meta_username my-username
이때 커맨드 옵션(-method=userpass)이 커맨드 인자(username=my-username)보다 앞에 와야 한다는 점을 눈여겨보세요.
github 인증 방식이 github-prod 경로에 활성화되어 있다면 이렇게 해요:
$ vault login -method=github -path=github-prod
Success! You are now authenticated. The token information below is already
stored in the token helper. You do NOT need to run "vault login" again. Future
requests will use this token automatically.
Key Value
--- -----
token s.2f3c5L1MHtnqbuNCbx90utmC
token_accessor JLUIXJ6ltUftTt2UYRl2lTAC
token_duration 768h
token_renewable true
token_policies ["default"]
identity_policies []
policies ["default"]
token_meta_org hashicorp
token_meta_username my-username
사용법 (Usage)
모든 명령어에 기본으로 포함된 표준 플래그 외에 다음 플래그들을 추가로 사용할 수 있어요.
출력 옵션 (Output options)
-field(string: "") —-format지시자에 지정된 형식으로, 이름이 주어진 필드만 출력해요. 결과 끝에 줄바꿈이 붙지 않아 다른 프로세스로 파이프하기에 좋아요.-format(string: "table") — 출력 형식을 지정해요. 유효한 값은"table","json","yaml"이에요.VAULT_FORMAT환경 변수로도 지정할 수 있어요.
커맨드 옵션 (Command options)
-method(string: "token") — 사용할 인증 타입을 지정해요. 예:"userpass","ldap". 이 값은 활성화 경로가 아니라 TYPE에 해당한다는 점에 주의하세요. 인증이 활성화된 경로를 지정하려면-path를 사용해요.-no-print(bool: false) — 토큰을 화면에 표시하지 않아요. 그래도 토큰은 설정된 토큰 헬퍼(token helper)에 저장돼요. 기본값은false예요.-no-store(bool: false) — 인증 후 이후 요청에 쓸 수 있게 토큰을 토큰 헬퍼(보통 로컬 파일시스템)에 저장하지 않아요. 토큰은 명령 출력에만 표시돼요.-path(string: "") — Vault에서 인증 방식이 활성화된 원격 경로를 지정해요. 기본값은 방식의 TYPE이에요(예:userpass→userpass/).-token-only(bool: false) — 검증 없이 토큰만 출력해요.-field=token -no-store의 단축 형태예요. 이 플래그들을 다른 값으로 설정해도 영향이 없어요.
더 알아보기 (Learn more)
vault auth— 인증 방식 관리vault token— 토큰 관리vault logout— 로그아웃