GithubHelp home page GithubHelp logo

brokebastard / hashitalk2019 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gmaentz/hashitalk2019

0.0 1.0 0.0 163.6 MB

Managing VMware Environments with HashiCorp Vault

HCL 4.81% PowerShell 95.19%

hashitalk2019's Introduction

Managing VMware Environments with HashiCorp Vault

VMware is the virtualization standard within the corporate datacenter. An all too common practice is to use common passwords for the most privileged accounts within VMware environments. How many VM admins utilize the same root password for all of their ESXi servers? When was the last time your root password for ESXi servers was changed? There has to be a better way.

In this talk we will showcase the evolution of managing VMware credentials. The goal will be to demonstrate how HashiCorp Vault can be used to help VMware Admins move to short-lived, dynamic credentials within ESXi and vSphere environments. Join us to learn:

  • How to use dynamic credentials within your VMware environment.
  • How VMware Admins can utilize existing tools like PowerCLI with HashiCorp Vault.
  • Ways you can use HashiCorp Vault to manage, control and rotate VMWare credentials in an automated manner.

VMware, PowerCLI and HashiCorp Vault

Managing VMware Environments with HashiCorp Vault

  • Discovery of ESXi hosts using PowerCLI
  • Pull root password for each ESXi host using Vault REST API
  • Generate unique passwords per host and update Vault
  • Version Passwords within Vault

Prerequisites / Vault Setup

  • HashiCorp Vault cluster that is reachable via PowerCLI. (Inbound TCP port 8200 to Vault)

Step 1: Configure Policies

Create Vault policy for 'vmadmins' with ACL settings specifed via vmadmins.hcl via the Vault UI

Picture?

Alternatively this can be done via the Vault CLI

vault policy write vmadmins policies/vmadmins.hcl

Step 2: Associate the vmadmins policy with the LDAP Group or user pass

Associate the VMware Admins Active Directory group with the Vault vmadmins policy.

vault write "auth/ldap/groups/VMware Admins" policies=vmadmins

If you are not using LDAP authentication withn Vault you can us an alternative authentication method. Below is an example associating username password authentication to the Vault vmadmins policy

vault write auth/userpass/users/vmadmin password={Your_Password} policies=vmadmins

Step 3: Enable the KV secrets engine and store ESXi passwords per host

  • A version 2 K/V secrets backend mounted at systemcreds
  • Passwords are stored under the Vault path: /systemcreds/esxihosts/$vmhost

Ex. ESXi passwords stored in Vault

Seed Vault with vCenter Discovery

Utilize esxi_password_seed.ps1 to connect to vCenter, loop through all hosts write them, along with the specified password to Vault.

.\esxi_password_seed.ps1 -vcenter {vcenter} -vaultserver {vault server} -hostpwd {PasswordtoSeed} -vaulttoken {vaulttoken}

Example:

.\esxi_password_seed.ps1 -vcenter vc.lab.local -vaultserver https://vault.lab.local:8200 -hostpwd NewP@ssw0rd

Step 4: Login as the User and Generate a Token

Login to the UI copy the token.

Copy Vault Token

Alternatively this can be done via the Vault CLI

vault token create -period 24h -policy vmadmins

Step 5: Update ESXi passwords using PowerCLI and Vault

Utilize esxi_password_update.ps1 to read the existing root password from Vault, connect to vCenter, loop through all hosts connected with vCenter, generate a random password and set it for each host, and record the new password with Vault - keeping a versioned history.

.\esxi_password_update.ps1 -vcenter {vcenter} -vaultserver {vault server -vaulttoken {vaulttoken}

Example:

.\esxi_password_update.ps1 -vcenter vc.lab.local -vaultserver https://vault.lab.local:8200

Automated - Rotate ESXi Host Passwords and Update Vault


Optional: Run the read password script to list root passwords stored in Vault

Utilize esxi_password_read.ps1 PowerCLI script to read the existing root password for all hosts in Vault.

Example:

.\esxi_password_read.ps1 -vcenter vc.lab.local -vaultserver https://vault.lab.local:8200

Automated - Read and Update Vault

Manual and Semi-Automated Alternatives:

Below are some of the manual and partially automated options for rotating ESXi root passwords:

Manual password updates with Web Interface and/or PowerCLI

Manual - Web Interfaces

PowerCLI

Changing an ESXi root password manually via PowerCLI.

$CurrentPassword = "VMware1!"
$NewPassword = "NewP@ssw0rd"
Connect-VIServer host1.lab.local -User root -Password $CurrentPassword
Set-VMHostAccount -UserAccount root -Password $NewPassword
Disconnect-VIServer host1.lab.local -Confirm:$False

Host Profiles

Changing an ESXi root password manually using Host Profiles.

Host Profiles (VMware Enterprise+ customers only)

*Note: Host Profiles are currently licesened to VMware Enterprise Plus customers only *


Batch password update across ESXi hosts using PowerCLI

Changing the ESXi root password of all hosts via PowerCLI.

Utilize esxi_password_batch_update.ps1 PowerCLI script to perform a batch update against all hosts within vCenter.

Batch Update - PowerCLI

.\esxi_password_batch_update.ps1 -vcenter {vcenter} -currentpwd {CurrentHostPassword} -newpwd {NewPassword to set}

Example:

.\esxi_password_batch_update.ps1 -vcenter vc.lab.local -currentpwd VMware1! -newpwd NewP@ssw0rd

hashitalk2019's People

Contributors

gmaentz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.