Originally published March 20, 2017 @ 1:00 pm
The esxcli
utility is used to interface with the vSphere and ESX hosts. It is a useful tool for getting to some basic VMWare functionality from the Unix shell. It is also a pre-requisite for some of the server deployment and configuration management tools, such as SaltStack.
Download the current version of VMware-vSphere-CLI from VMWare or version 6. Place it in /tmp and extract. Run the installation script, accept the defaults:
cd /tmp tar xvfz VMware-vSphere-CLI-6.0.0-2503617.x86_64.tar.gz cd vmware-vsphere-cli-distrib ./vmware-install.pl
Install Python tools and pre-requisites for esxcli:
yum -y install python-pip openssl-devel libxml2-dev e2fsprogs-dev pip install pyVmomi
Test network connection to the vCenter server:
nc -v -i 1 -w 1 vcenter01 443
Obtain vCenter host’s thumbprint:
esxcli -s vcenter01 -u 'DOMAIN\SvcAccount' -p '********' >> Connect to vcenter01 failed. Server SHA-1 thumbprint: 3E:7D:46:C3:83:7C:80:9F:3A:06:DE:23:F0:FA:EB:48:7C:EC:33:8F (not trusted)
Add the vCenter host and its thumbprint to the local credential store:
/usr/lib/vmware-vcli/apps/general/credstore_admin.pl add --server vcenter01 --username 'DOMAIN\SvcAccount' -p '********' /usr/lib/vmware-vcli/apps/general/credstore_admin.pl add --server vcenter01 --thumbprint 3E:7D:46:C3:83:7C:80:9F:3A:06:DE:23:F0:FA:EB:48:7C:EC:33:8F
Verify functionality:
esxcli -s vcenter01 -u 'DOMAIN\SvcAccount' -p '*********' --vihost=esxi_host_01 vm process list Sample output: vmrhel701 World ID: 6458879 Process ID: 0 VMX Cartel ID: 6458878 UUID: 42 3c 02 72 9b 74 87 41-dd c8 b4 7a 96 64 13 c6 Display Name: vmrhel701 Config File: /vmfs/volumes/1b48c93f-ad74f785/vmrhel701/vmrhel701.vmx
You can also connect directly to individual ESX hosts, but you will need to add their thumbprints to your local credential store. You can obtain the list of ESX hosts in your data center by using PowerCLI:
Set-PowerCLIConfiguration -Scope Session -WebOperationTimeoutSeconds -1 -Confirm:$false; Import-Module VMware.VimAutomation.Vds; $VMHost="vcenter01"; Connect-VIServer -Server $VMHost -User 'DOMAIN\SvcAccount' -Password '*********'; Get-VMHost | Select Name | ConvertTo-Csv -NoTypeInformation | % {$_ -replace '"', ""} | Select-Object -Skip 1 | Out-File C:\users\esx_list.txt -Force -Encoding ascii
The script below will loop through a list of ESX hosts, obtain their thumbprints, and add them to the local credential store.
#!/bin/bash listfile="" if [ -z "${listfile}" ] || [ ! -r "${listfile}" ] then exit 1 fi username="DOMAIN\SvcAccount" password="********" credstoreadmin="/usr/lib/vmware-vcli/apps/general/credstore_admin.pl" for i in $(cat "${listfile}") do echo "Adding ${i}" tumbprint="$(esxcli -s "${i}" -u "${username}" -p "${password}" | grep -oE "([A-Z0-9]{2}:){19}[A-Z0-9]{2}")" ${credstoreadmin} add --server "${i}" --username "${username}" --password "${password}" ${credstoreadmin} add --server "${i}" --thumbprint "${tumbprint}" done
Experienced Unix/Linux System Administrator with 20-year background in Systems Analysis, Problem Resolution and Engineering Application Support in a large distributed Unix and Windows server environment. Strong problem determination skills. Good knowledge of networking, remote diagnostic techniques, firewalls and network security. Extensive experience with engineering application and database servers, high-availability systems, high-performance computing clusters, and process automation.