How to install HashiCorp Vault and Consul in Ubuntu 21.04

Share this article

Vault stores sensitive information, such as API keys, login credentials, or even files (e.g. certificates and private keys). It is a management system that also controls and protects sensitive information by ensuring this information is encrypted during transit and at rest.

Vault is open source and can be deployed in several different ways, In this article, we will install Vault and Consul by adding the Harshicorp repository.

Add GPG key

Command :

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -

Add HashiCorp Linux repository

Command

sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"

Update and install Vault

Command:

sudo apt-get update && sudo apt-get install vault

Verify the Installation

After Vault installation, verify the installation by running the vault command on the terminal. See the following snapshot to check out whether it is installed or not.

Install Consul

Consul is a distributed service discovery and storage system. We are using Consul Storage as a back-end to Vault to ensure the software is highly available and fault-tolerant.

Command

sudo apt-get install consul

Verifying the Installation

After Consul installation, verify the installation by running the Consul command on the terminal. See the following snapshot to check out whether it is installed or not.

Configuring Vault backend with Consul

In vault /etc/vault.d/vault.hcl configuration file change the storage to Consul shown in below mentioned code section.

storage "consul" {
  address = "127.0.0.1:8500"
  path    = "vault/"
}

Also, see the content of the /etc/vault.d/vault.hcl in the below-mentioned snapshot.

After changing the configuration restart the Vault service by running below mentioned command.

sudo service vault restart

Leave a Comment

Your email address will not be published. Required fields are marked *