Emergency server help: get in touch

Enable SSH on ESXi and the 40 esxcli commands every VMware admin needs

Turn on SSH for ESXi 7, 8 and 9 from the client, DCUI or PowerCLI, lock it down, and keep a working set of esxcli commands for host, network, storage, VM, software and hardware checks that cover daily operations.

Published Updated 13 min read

The vSphere Client covers most daily work, but there is a class of problems (hung VMs, stuck tasks, storage paths, driver versions) that is faster and clearer from the host shell. esxcli is the structured command line for ESXi; its namespaces mirror the host’s subsystems and its output is consistent across ESXi 7.0, 8.0 U3 and 9.x. This guide first covers enabling SSH properly, then lists the commands we reach for most, grouped by task.

Short answer: Enable SSH temporarily from the vSphere Client under host » Configure » Services » SSH » Start (or in the DCUI under Troubleshooting Options), keep the service policy at “Start and stop manually” so it does not survive a reboot, and restrict it with the ESXi firewall to your management subnet. Then use esxcli namespaces such as esxcli system, esxcli network, esxcli storage, esxcli vm and esxcli software to inspect and change the host; esxcli --help at any level lists what is available. (Reviewed November 2026.)

Enable SSH the safe way

In the vSphere Client: select the host » Configure » System » Services » SSH » Start. Leave the startup policy at manual. From PowerCLI across one cluster, name the vCenter and the cluster explicitly, check the host list, then start and later stop SSH on that same captured list. A bare Get-VMHost returns every host on every vCenter in the session’s default server list, which can be far more than one cluster:

$vc = Connect-VIServer -Server vcenter01.example.com
$esxHosts = Get-Cluster -Name "Cluster01" -Server $vc | Get-VMHost
$esxHosts | Select-Object Name, ConnectionState     # check this is exactly the list you expect

# start SSH on those hosts only
$esxHosts | Get-VMHostService | Where-Object Key -eq "TSM-SSH" | Start-VMHostService

# when the work is done, stop it on the same list
$esxHosts | Get-VMHostService | Where-Object Key -eq "TSM-SSH" | Stop-VMHostService -Confirm:$false
$esxHosts | Get-VMHostService | Where-Object Key -eq "TSM-SSH" | Select-Object VMHost, Running

From the DCUI: F2 » Troubleshooting Options » Enable SSH. Restrict the source with the firewall once connected:

esxcli network firewall ruleset set -r sshServer -a false
esxcli network firewall ruleset allowedip add -r sshServer -i 10.10.0.0/24
esxcli network firewall ruleset list -r sshServer

Two separate timeouts limit SSH, both in seconds under Advanced System Settings. UserVars.ESXiShellTimeOut is a service timeout: that long after SSH is started, ESXi stops the SSH and ESXi Shell services again, so new logins fail while sessions already open carry on. UserVars.ESXiShellInteractiveTimeOut is an inactivity timeout that logs out a session left idle that long. Both are 0 (off) on a default install. Setting both means a forgotten service turns itself off and a forgotten session closes:

esxcli system settings advanced set -o /UserVars/ESXiShellTimeOut -i 3600            # service stops 1 hour after start
esxcli system settings advanced set -o /UserVars/ESXiShellInteractiveTimeOut -i 900  # idle session closes after 15 minutes
esxcli system settings advanced list -o /UserVars/ESXiShellTimeOut

If SSH keeps switching itself off after exactly an hour even though its startup policy is “Start and stop with host”, ESXiShellTimeOut is set to 3600 on that host. The warning “SSH for the host has been enabled” in the client is by design; suppress it only on lab hosts.

Host and system

esxcli system version get
esxcli system hostname get
esxcli system maintenanceMode get
esxcli system settings advanced list -o /Misc/APDTimeout
esxcli system ntp get
esxcli system syslog config get
esxcli system boot device get
esxcli system account list
esxcli system stats uptime get

Everything in this section and the networking, storage, VM and hardware lists below only reads state, so it is safe on a production host at any time. Commands that change the host are grouped separately under Maintenance and image updates.

Networking

esxcli network nic list
esxcli network nic get -n vmnic0
esxcli network ip interface list
esxcli network ip interface ipv4 get
esxcli network ip route ipv4 list
esxcli network ip dns server list
esxcli network vswitch standard list
esxcli network vswitch dvs vmware list
esxcli network firewall get
esxcli network ip connection list

esxcli network nic get shows link state, speed and driver; ip connection list is the netstat equivalent when you need to see what a host is talking to.

Storage

esxcli storage core adapter list
esxcli storage core device list
esxcli storage core path list
esxcli storage nmp device list
esxcli storage filesystem list
esxcli storage vmfs extent list
esxcli storage nfs list
esxcli iscsi adapter list
esxcli iscsi session list

Path and device lists are the first stop for the APD and PDL states described in Fix ESXi “Datastore not accessible”. esxcli storage core device stats get gives per-device error counters when latency is in question.

To list running virtual machines with their world IDs:

esxcli vm process list

esxcli’s VM namespace is deliberately small; pair it with vim-cmd vmsvc/getallvms, vim-cmd vmsvc/power.getstate <id> and vim-cmd vmsvc/get.tasklist <id> for inventory and task work, as covered in Kill an unresponsive VM on ESXi.

Software and hardware

esxcli software profile get
esxcli software vib list
esxcli software vib get -n nvme-pcie
esxcli software sources profile list -d /vmfs/volumes/ds1/depot.zip
esxcli hardware cpu list
esxcli hardware memory get
esxcli hardware platform get
esxcli hardware ipmi sel list

esxcli hardware platform get returns the model and serial number without a trip to the data centre, and ipmi sel list reads the hardware event log for failed DIMMs and PSU events.

Every esxcli command accepts --formatter for scripting:

esxcli --formatter=csv network nic list
esxcli --formatter=keyvalue storage filesystem list
esxcli --formatter=json system version get

JSON output pairs well with a monitoring agent that shells in over SSH, though the vSphere API is the better long-term choice for anything polled regularly.

Maintenance and image updates

These commands change the host or a running VM. Run the image update only in a planned maintenance window, after VMs are migrated or powered off, and on hosts managed by vSphere Lifecycle Manager use Lifecycle Manager instead of a manual image update:

esxcli system maintenanceMode set --enable true
esxcli software profile update -d /vmfs/volumes/ds1/depot.zip -p <profile> --dry-run
esxcli software profile update -d /vmfs/volumes/ds1/depot.zip -p <profile>
esxcli system shutdown reboot -r "patching"      # requires maintenance mode
esxcli system maintenanceMode set --enable false

The worked example below walks through the full patch sequence with the checks between steps.

Two commands from day-to-day troubleshooting also act on the host rather than only reading it:

esxcli storage core adapter rescan --all              # rescans every storage adapter
esxcli vm process kill --type=soft --world-id=<id>   # ends that VM's process; the guest gets no clean shutdown

A rescan finds new LUNs and drops missing ones from the device list. On a host with many paths it can take minutes and adds storage load, and during an APD or PDL event run it only as one of the recovery steps in the datastore not accessible guide. Any vm process kill, including --type=soft, terminates the running VM: the guest operating system is not shut down and unsaved data inside it is lost. Try a guest shutdown or power-off from vSphere first. soft lets the VMX process clean up, hard stops it immediately, and force is the last resort; get the world ID from esxcli vm process list.

Worked example: patch a standalone host

This is the sequence for applying an offline depot (a vendor or Broadcom patch ZIP copied to a datastore) to a host that is not managed by vSphere Lifecycle Manager. Power off or migrate the VMs first; maintenance mode will not complete while VMs are still running on the host.

esxcli system maintenanceMode set --enable true
esxcli software sources profile list -d /vmfs/volumes/ds1/depot.zip
esxcli software profile update -d /vmfs/volumes/ds1/depot.zip -p <profile> --dry-run
esxcli software profile update -d /vmfs/volumes/ds1/depot.zip -p <profile>
esxcli system shutdown reboot -r "patching"
# after the host is back
esxcli system version get
esxcli system maintenanceMode set --enable false

--dry-run reports the VIB-level changes without touching the host, so read its output before the real run. Use profile update, not profile install: update upgrades VIBs but never removes them, while install replaces the whole image and can drop vendor drivers that are not in the profile. Broadcom’s help text also warns to disable HA first if the update needs a reboot. In a cluster managed by Lifecycle Manager images, patch through Lifecycle Manager instead so the host does not drift from the cluster image.

Worked example: send logs to a remote syslog server

ESXi rotates its local logs quickly, and on a host without persistent scratch storage they can be lost at reboot. A remote collector keeps the record of SSH logins that the clean-up advice below relies on. Point the host at a collector and open the outbound ruleset:

esxcli system syslog config set --loghost='tcp://192.0.2.50:514'
esxcli system syslog reload
esxcli network firewall ruleset set --ruleset-id=syslog --enabled=true
esxcli network firewall refresh
nc -z 192.0.2.50 514
esxcli system syslog mark --message "srvscripts syslog test"

nc -z checks that the TCP port is reachable from the host, and syslog mark writes a test line you can search for on the collector. Use udp:// or ssl:// in the loghost if your collector expects them. From ESXi 8.0 Update 2b, syslog opens non-standard loghost ports with its own dynamic firewall rules; standard ports still need the syslog ruleset enabled as above.

Test VMkernel connectivity and MTU

Storage and vMotion problems are often a VMkernel adapter that cannot reach its peer, or an MTU mismatch somewhere on the path. Ping from a specific VMkernel interface rather than letting the host choose:

esxcli network ip interface list
esxcli network diag ping -H 192.0.2.20 -I vmk1 -c 3
esxcli network diag ping -H 192.0.2.20 -I vmk1 -s 8972 --df -c 3

--df sets the Don’t Fragment bit, and 8972 bytes is a 9000-byte MTU minus 28 bytes of IP and ICMP headers (use 1472 for a 1500 MTU). If the small ping works and the large one fails, one hop (the vmk, the vSwitch, the uplink or a physical switch port) is still at a smaller MTU.

Clean up and avoid the common pitfall

After finishing, stop SSH (Stop-VMHostService or the client) and confirm the TSM-SSH service shows as stopped in the host client (Manage, Services) or with $esxHosts | Get-VMHostService | Where-Object Key -eq 'TSM-SSH' on the host list from the start of this guide. Host profiles and Lifecycle Manager can flag hosts with SSH left running, which is a useful compliance check.

Setting the SSH policy to “Start and stop with host” for convenience leaves an interactive root shell exposed on every host permanently. Combined with a shared root password, it undermines every other control. Enable on demand, use lockdown mode with an exception user for automation, and forward the auth log to syslog so logins are visible.

esxcli, localcli, vim-cmd or PowerCLI?

Four tools overlap on an ESXi host. Pick by what you need to do and whether the management stack is healthy:

ToolBest forKeep in mind
esxcliDay-to-day host inspection and changes from the shellThe standard tool, for local and remote use; most commands in this guide
localcliTroubleshooting when hostd is unavailable or unresponsiveBypasses hostd and the normal management processes; not a routine replacement for esxcli
vim-cmdVM inventory, power state and task listsFills the gaps in the small esxcli vm namespace
PowerCLI Get-EsxCli -V2Running the same esxcli namespaces across many hostsUses the vSphere API, so SSH can stay off

Troubleshooting and rollback

Most problems here come from the firewall restriction, maintenance mode or an unhealthy management agent:

SymptomLikely causeFix
SSH stops working right after allowedip addYour workstation is not inside the allowed range, or the range has a typoFrom the vSphere Client, the DCUI or PowerCLI (none use the sshServer ruleset) run esxcli network firewall ruleset allowedip list -r sshServer, fix it with allowedip remove / add, or undo with esxcli network firewall ruleset set -r sshServer -a true
The scripted reboot refuses to runThe host is not in maintenance modeesxcli system maintenanceMode set --enable true, then retry
Maintenance mode never completesVMs are still running on the hostesxcli vm process list shows what is left; migrate or shut those VMs down
esxcli hangs or errors while the host shows Not Respondinghostd is unresponsiveUse localcli for read-only checks, then restart only hostd with /etc/init.d/hostd restart. Broadcom warns against services.sh restart on hosts with vSAN, LACP or NSX
No SSH and no DCUI accessStrict lockdown mode stops the DCUIExit lockdown from the host’s Security Profile in the vSphere Client via vCenter; in strict mode only Exception Users with SSH or ESXi Shell enabled can still get in

To undo the SSH changes from this guide entirely: set the sshServer ruleset back to -a true, stop the SSH service, and put UserVars.ESXiShellInteractiveTimeOut back with esxcli system settings advanced set -o /UserVars/ESXiShellInteractiveTimeOut -d, which restores the default value.

Esxcli commands at a glance

Enable SSH on ESXi and the 40 esxcli commands every VMware a summary card: Enable SSH temporarily from the vSphere Client under host » Configure » Services » SSH » Start (or in the DCUI under…
In short: Enable SSH temporarily from the vSphere Client under host » Configure » Services » SSH » Start (or in the DCUI under Troubleshooting Options), keep the service policy at “Start and stop manually” so it does not survive a reboot, and…
esxcli commands – questions answered
esxcli commands: the questions this guide answers.

Official documentation: Broadcom TechDocs (VMware), ESXCLI command reference, PowerCLI Get-VMHost reference, Broadcom KB 441004: SSH service stops after 60 minutes.

Related guides: Upgrade ESXi 8 to 9.1 with esxcli and vLCM · ESXi APD and PDL: datastore not accessible · Kill an unresponsive VM on ESXi · Upgrade vCenter Server Appliance 8.0 to 9.x with the Migration Assistant.

Frequently asked questions

Does esxcli work the same on ESXi 9 as on 7 and 8?

The namespaces and commands listed here exist on all three, with 9.x adding options rather than removing them. A few storage and network subcommands gained fields in 8.0; esxcli <namespace> --help shows the exact syntax for the build you are on.

How long can SSH stay enabled on an ESXi host?

Not by default. When UserVars.ESXiShellTimeOut is set above 0, ESXi stops the SSH service that many seconds after it starts, so new logins fail while open sessions continue. UserVars.ESXiShellInteractiveTimeOut is a separate setting that closes idle sessions. Both are 0 (off) on a default install. Treat any host with SSH running for more than a maintenance window as a finding.

Can I run esxcli remotely without SSH?

Yes. PowerCLI’s Get-EsxCli -V2 exposes the same namespaces through the vSphere API, and the standalone ESXCLI package can target a host over HTTPS with --server. Both avoid an open shell on the host.

How do I take an ESXi host out of maintenance mode from the command line?

Run esxcli system maintenanceMode set --enable false, then confirm with esxcli system maintenanceMode get, which should return Disabled. The same command with --enable true puts the host into maintenance mode.

When should I use localcli instead of esxcli?

Only when hostd is unavailable or unresponsive and esxcli hangs. localcli bypasses hostd and talks to the system directly, which makes it a troubleshooting tool rather than an everyday replacement for esxcli.

Share this guide

Free website test

Is your website set up right?

Check SSL, security headers, redirects, robots.txt, sitemap, llms.txt and security.txt in one test. It takes about 30 seconds.