Configure SSH for HashiCorp Vault Authentication

2 hours
  • 5 Learning Objectives

About this Hands-on Lab

In this hands-on lab, you will be required to configure a HashiCorp Vault to generate SSH one-time passwords for a client on request. In order to achieve this, we will need to configure both the SSH Client, and the HashiCorp Vault servers.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Unseal the Vault and Log in with the Root Token
  1. Retrieve the vault keys.
  2. Unseal the vault.
  3. Log in with the Initial Root Token.
Enable SSH Secrets Engine and Provide Access to `ssh/creds/otp_role`
  1. Enable SSH Secrets engine.
  2. Create an otp_role with key type otp.
  3. Create a policy file to provide access to ssh/creds/otp_role.
  4. Write a policy based on the otp-policy.hcl file.
Enable the `userpass` Authentication Method
  1. Enable userpass.
  2. Create a user and assign the otp-policy.
Install `vault-ssh-helper` and Configure SSH
  1. On the SSH Client server, download vault-ssh-helper.
  2. Add the ubuntu user.
  3. Unzip the vault-ssh-helper_0.1.6_linux_amd64.zip file and move it to /usr/local/bin.
  4. Update the permissions on the vault-ssh-helper binary.
  5. Change ownership of the binary from the cloud_user, to the root user, and root group.
  6. Create a new directory named vault-ssh-helper.
  7. Create a configuration file for vault-ssh-helper.
  8. Modify the pam.d/sshd configuration file.
  9. Modify the sshd configuration file.
  10. Restart sshd to apply the changes.
  11. Run vault-ssh-helper verification.
Log in with the `userpass` Credentials, and Generate the One-Time Password
  1. On the Vault server, log in with the userpass credentials.
  2. Create a one-time password and copy the key for later use.
  3. From the Client server, use the one-time password to connect to the SSH Client server.

Additional Resources

  1. Use dig to get the domain name of the server or open the Domain file:
    dig -x <SERVER PUBLIC IP>
    cat /home/cloud_user/Domain
  2. Vault keys and root token are located at:
    /home/cloud_user/Keys

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?