
This assumes the following has already been done.
- Hashicorp Vault has been installed
- Hashicorp Vault has been initialized
- Hashicorp Vault has been unsealed
When starting the vault, the initial root token will be displayed, like this.
Initial Root Token: s.gYGVHcHMiGsCZdKAJzWq1Yj1
The vault login command can be used to log into the vault. In this example, the log in will be done as root.
vault login s.gYGVHcHMiGsCZdKAJzWq1Yj1
If you installed the vault CLI on a system different from the system that Hashicorp Vault was installed on, include the -address option where address will be something like http://vault.example.com:8200.
vault login -address <address> s.gYGVHcHMiGsCZdKAJzWq1Yj1
Or by exporting the VAULT_ADDR variable.
export VAULT_ADDR=https://vault.example.com:8201
And the following should be displayed.
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.gYGVHcHMiGsCZdKAJzWq1Yj1
token_accessor Z0Q8To48Rkkgx7zka-dqsDjJ
token_duration ∞
token_renewable false
token_policies ["root"]
identity_policies []
policies ["root"]
And the vault auth list command should return something like this.
~]$ vault auth list
Path Type Accessor Description Version
---- ---- -------- ----------- -------
token/ token auth_token_5013c38c token based credentials n/a
If you enabled approle and have created a role ID and secret ID, you can then login to the vault using the approle role ID and secret ID.
~]$ vault write auth/approle/login role_id=76390ed2-e61c-9ef3-a438-0a2b736330bc secret_id=1b7cfc8c-c11c-73b1-dc22-1326ff6604ed
Key Value
--- -----
token hvs.CAESIOeRP8HgRmd5ljtProEbLlPspAlyov0LFTTequUKdnhFGh4KHGh2cy5teHhjRlI3ejlhdVVBUHpSTkpRcVpDRGU
token_accessor N1aLX6Jol2IZsUcUOquXbJNj
token_duration 20m
token_renewable true
token_policies ["default"]
identity_policies []
policies ["default"]
token_meta_role_name my-role
Did you find this article helpful?
If so, consider buying me a coffee over at