Set up and configure Vault
To set up and configure Vault, perform the following steps:
- Download and install Vault.
- Configure Vault.
- Configure TCP listeners in the Vault configuration file.
- Start the dev server.
- Verify the server is running.
- Access the Vault UI and modify the default ACL policy.
- (Optional) Restart the dev server if it times out.
The following sections show you how to perform these tasks.
This integration guide assumes you are running the Vault server in Dev mode. When deploying Vault in a production setting, you must consider other things, such as the storage backend, but most concepts apply to dev and production. For specifics on how to deploy Vault in a production environment, refer to the HashiCorp Vault documentation: https://learn.hashicorp.com/tutorials/vault/getting-started-deploy.
For more information about how the dev server works, refer to https://www.vaultproject.io/docs/concepts/dev-server.
Refer to the HashiCorp Vault documentation at the following link for instructions on how to download and install the Vault application: https://www.vaultproject.io/docs/install
The second installation option at the preceding link uses a precompiled binary. Download these binaries at the following url: https://www.vaultproject.io/downloads
To verify Vault works, run the following command on your system. You should see the help output. If you execute it from the command line, make sure the vault command is on your PATH or you might get an error about Vault not being found.
Vault uses documented sane defaults, so you need to set only non-default values in the configuration file.
Run the following command to create the /etc/vault.d directory:
Run the following command to create a Vault configuration file, vault.hcl:
Run the following command to create a unique, non-privileged system user to run Vault:
Run the following command to set the ownership of the /etc/vault.d directory:
Run the following command to set the file permissions:
To configure the TCP listener addresses, you must edit the listener stanza, or selection of lines, in the vault.hcl fle on your server.
The TCP listener configures Vault to listen on a TCP address and port, as shown in the following example:
You can specify the listener stanza more than once to make Vault listen on multiple interfaces. If you configure multiple listeners, you also need to specify api_addr and cluster_addr so Vault advertises the correct address to other nodes.
The following sample vault.hcl configuration file (used for demonstration in this guide) shows Vault listening on a private interface, as well as localhost.
You must customize the values defined in the vault.hcl file for each specific use case (such as IP addresses, ports, and file paths to certificates).
The comments above each block in the file explain what the define lines do.
Critically, note that 10.0.5.118 is the IP address of the machine that Vault is installed on, and 8210 is the port on which Vault listens for requests from the KMES Series 3.
Also, make sure that the client certificate common name matches the IP address set in vault.hcl. Otherwise, the KMES Series 3 does not verify the certificates presented by Vault to the KMES Series 3.
cluster_address is not defined in the sample vault.hcl file because this demo uses only a single Vault server.
For more information about configuring the Vault configuration file, see the Vault documentation at the following URL: https://learn.hashicorp.com/tutorials/vault/configure-vault
To start the Vault dev server, run the following command:
You should see output similar to the following example. Notice that Unseal Key and Root Token values display.
The dev server stores all its data encrypted in memory, listens on localhost without TLS, and automatically unseals and shows you the unseal key and root access key.
With the dev server started, perform the following steps:
Launch a new terminal session.
Set the VAULT_ADDR environment variable value by running the following command in the terminal. This configures the Vault client to talk to the dev server.
Vault CLI uses the VAULT_ADDR environment variable to determine to which Vault servers to send requests.
Save the unseal key somewhere. You don't need to save this securely.
Set the VAULT_TOKEN environment variable value to the generated Root Token value displayed in the terminal output when you started the dev server.
To interact with Vault, you must provide a valid token. Setting this environment variable provides the token to Vault through the CLI.
Verify the server is running by executing the vault status command. If it started properly, the output should look similar to the following example:
In the Enterprise version of Vault, the dev server seals itself 30 minutes after you start it. This means that for the Enterprise version of Vault, you must perform the steps in the Restart the dev server if it times out section every time the dev server times out.
For more information about how the dev server works, refer to https://www.vaultproject.io/docs/concepts/dev-server.
Go to http://localhost:8200 in a web browser.
Copy and paste the Root Token in the Token field and select [ Sign In ]. The Root Token displays in the output of the vault server command you used to start the dev server.
After signing in, perform the following steps to modify the default ACL policy:
Go to the Policies menu, then select the default ACL policy.
Select [ Edit Policy ], scroll to the bottom of the policy, and paste the following lines starting at line 89 of the policy:
Select [ Save ].
A message confirms that the ACL policy default was successfully saved.
In the Enterprise version of Vault, the dev server seals itself 30 minutes after you start it. This means that for the Enterprise version of Vault, you must perform the following steps every time the dev server times out:
Trigger a Vault shutdown by using CTRL+C in the terminal window where you started the Vault server.
Run the following command in a terminal:
Perform again the steps outlined in the following sections:
- Configure Vault
- Start the dev server
- Access the Vault UI
- Modify the default ACL policy
Re-configure either the userpass or TLS authentication auth method in Vault, as described in section Set up authentication between the KMES Series 3 and Vault.