Secure VMware with Mondoo
Continuously assess VMware vSphere and ESXi hosts for security vulnerabilities and misconfigurations.
VMware vSphere and ESXi often form the foundation of on-premises infrastructure, so keeping them secure protects every workload running on top of them. Mondoo assesses them from a Linux host that runs cnspec.
The setup has three parts:
- Create a read-only vCenter user that Mondoo will scan with.
- Deploy a Linux host with cnspec to run the scans. Mondoo ships a pre-built VMware appliance, or you can install cnspec on your own hardened Linux instance.
- Register cnspec and run scans against vSphere and ESXi.
Step 1: Create a read-only vCenter user
Mondoo needs a read-only vCenter user. Create a role, then create a user assigned to it.
-
On the vSphere Client main menu, select Administration > Roles.
-
Select the Read-only role and select CLONE.
-
Name the clone Mondoo read-only role and select OK.

-
Select the new role and select EDIT. In the left list, select Global; in the right list, check Settings. Select SAVE.

-
On the Administration menu, select Users and Groups.
-
Under Users, select the vsphere.local domain and select ADD.
-
Name the user mondoo-read, set a password, and select ADD.

-
On the Administration menu, select Global Permissions > ADD, then assign the Mondoo Read-only role to the mondoo-read user. Check Propagate to children and select OK.

Step 2: Deploy a scan host
You can use the pre-built Mondoo VMware appliance or install cnspec on your own hardened Linux instance.
Option A: Mondoo VMware appliance
The appliance is a pre-configured Debian 13 VM with cnspec, VMware tools, cloud-init, and dev-sec hardening already in place. It manages its network with systemd-networkd.
-
Download the Mondoo OVA image.
-
In vCenter, right-click your Datacenter and select Deploy OVF Template.

-
Select the OVF template by URL or local file, then step through the wizard (name, folder, compute, storage, network).

-
On the wizard's Customize template page, set the appliance's deployment properties. Every property is optional:
Property What it sets Hostname The appliance's hostname. Default mondoo-appliance.Network Mode dhcp(default) orstatic.Static IP Address, Netmask or Prefix, Gateway The static address, for example 192.168.1.50,255.255.255.0or24, and192.168.1.1. A static network needs all three. If one is missing, the appliance starts without a network configuration.DNS Servers Comma-separated DNS servers for a static network, for example 1.1.1.1,8.8.8.8.Configure Proxy, HTTP Proxy URL, HTTPS Proxy URL, No Proxy An HTTP and HTTPS proxy for the appliance. Set Configure Proxy to trueto use them. No Proxy lists the addresses that bypass the proxy. Defaultlocalhost,127.0.0.1.NTP Server The time server. Default pool.ntp.org.Timezone The appliance's time zone. Default UTC.Keyboard Layout The console keyboard layout. Default us.SSH Public Key An SSH public key ( ssh-rsaorssh-ed25519) to add to themondoouser'sauthorized_keys.Mondoo Registration Token A registration token for the space the appliance reports to. With a token, the appliance registers cnspec at first boot, runs a first scan of itself, and starts the cnspec service, so you can skip the cnspec logincommand in Step 3.Cloud-Init User-Data, User-Data Encoding, Cloud-Init Meta-Data, Meta-Data Encoding Your own cloud-init configuration, encoded as gzip+base64orbase64. If you provide user-data, the appliance configures itself only through cloud-init and ignores every other property in this table except the meta-data.
The appliance applies these properties once, at first boot. To see what it applied, sign in and run sudo ovf-debug.
The appliance ships with default credentials mondoo / mondoo. Change the password on first login. Password login is disabled by default on the hardened image. To sign in over SSH, set the SSH Public Key property when you deploy, or add your key to /home/mondoo/.ssh/authorized_keys from the VM console.
Optional: enable password authentication temporarily
If you can't transfer your SSH key first, enable password auth temporarily:
- In
/etc/ssh/sshd_config:AuthenticationMethods password PasswordAuthentication yes - Restart sshd:
systemctl restart sshd.service
Optional: change to a static IP address after deployment
To set a static address when you deploy, use the Network Mode property instead. To change the network configuration later, edit the appliance's systemd-networkd files. At first boot, the appliance writes its network settings to /etc/systemd/network/10-ovf-dhcp.network (DHCP) or /etc/systemd/network/10-ovf-static.network (static).
Run as root.
-
Find the name of the network interface, for example
ens192, withip link. -
Delete
/etc/systemd/network/10-ovf-dhcp.networkif it exists. -
Create or edit
/etc/systemd/network/10-ovf-static.network. Example forens192:[Match] Name=ens192 [Network] Address=192.168.1.100/24 Gateway=192.168.1.1 DNS=192.168.1.1 DNS=8.8.8.8 LinkLocalAddressing=no IPv6AcceptRA=no -
Apply the change:
systemctl restart systemd-networkd systemd-resolved.
If the new IP differs from the current one, your SSH session drops; reconnect to the new address.
Option B: Your own Linux host
Install cnspec on any hardened Linux instance. See the cnspec installation guide.
Step 3: Register cnspec with Mondoo
The Mondoo App's VMware page generates the registration command for you. In the side navigation
bar, select Integrations, then INSTALL, and under Cloud Security select VMware.
Under Log in and scan your VMware environment, the page shows a cnspec login command with a
fresh registration token (select REFRESH TOKEN if it expires) and a sample scan command. The
same page lets you enable security policies for vSphere and ESXi.
-
Register the host with a registration token. If you deployed the appliance with the Mondoo Registration Token property, it registered itself at first boot. Run step 2 to confirm, and run this command only if the status check shows the client isn't registered.
sudo cnspec login -t <token> --config /etc/opt/mondoo/mondoo.yml -
Verify registration:
sudo cnspec statusThe first lines of the output summarize the result. A healthy registration reads:
● Client registered ✓ authenticated ● Platform reachable · SERVING ✓ healthyThe output ends with
✓ all systems healthy. If it doesn't, see What to do when status fails. -
Run a first test scan against vSphere:
cnspec scan vsphere mondoo-read@vsphere.local@host --ask-passAdd
--incognitoto skip sending results to the Mondoo App for the first test scan. -
In the Mondoo App, enable the policies you want to score against. Mondoo VMware vSphere Security Baseline (for vCenter) and Mondoo VMware vSphere ESXi Security (for ESXi hosts) are a good starting point. See Manage Policies.
-
Run the scan again to send results to the Mondoo App:
cnspec scan vsphere mondoo-read@vsphere.local@host --ask-pass --discover auto--discover autofinds all ESXi hosts and the vCenter automatically. Use--discover allto also discover VMs.
vSphere tags and labels
When cnspec discovers ESXi hosts and VMs through vCenter, it labels each asset with vsphere.vmware.com/name, vsphere.vmware.com/moid, and its inventory path (vsphere.vmware.com/inventorypath on hosts, vsphere.vmware.com/inventory-path on VMs). It also adds each vSphere tag attached to the host or VM as the label vsphere.vmware.com/tag/CATEGORY:TAG with the value true. If cnspec can't look up the tag's category, the key is vsphere.vmware.com/tag/TAG. cnspec discovers VMs only with --discover all or --discover instances, so VMs carry these labels only then.
You can filter on these labels and build workspaces from them. For example, a workspace with a Tags/Labels CONTAINS condition with the key vsphere.vmware.com/tag/Environment:production and the value true includes every host and VM tagged production in the Environment category. To learn more, read Group assets by AWS account or vSphere tag.
Scan multiple assets with an inventory file
An inventory file lets cnspec scan multiple VMware assets on a schedule. The basic file looks like this:
apiVersion: v1
kind: Inventory
metadata:
name: cnspec-inventory
labels:
environment: production
spec:
assets:
- name:
connections:
- type: vsphere
host: <ip of the ESXi or vCenter>
insecure: true
credentials:
- type: password
user: <username>
password: <password>
discover:
targets:
- host-machinesSave the file at /etc/opt/mondoo/inventory.yml as root so cnspec picks it up automatically, then:
sudo cnspec scan --inventory-file /etc/opt/mondoo/inventory.yml
sudo systemctl restart cnspec
sudo systemctl enable cnspecConfirm the inventory loaded with sudo journalctl -u cnspec.service.
Use an encrypted file vault for credentials
To avoid plaintext credentials in inventory.yml, use cnspec's encrypted file vault.
-
Configure the vault as the
mondoouser (notroot):cnspec vault configure mondoo-client-vault --type encrypted-file \ --option=password='changeme' \ --option path='/etc/opt/mondoo/vault.enc'cnspec prints a vault configuration block; add it to your inventory file.
-
Update the inventory to reference the vault by secret ID:
/etc/opt/mondoo/inventory.yml apiVersion: v1 kind: Inventory metadata: name: cnspec-inventory labels: environment: production spec: assets: - name: connections: - type: vsphere host: 192.168.51.134 insecure: true credentials: - secret_id: vcenter discover: targets: - host-machines vault: name: mondoo-client-vault options: password: changeme path: /etc/opt/mondoo/vault.enc type: encrypted-file -
Store the vSphere credentials in the vault:
cnspec vault add-secret vcenter \ '{ "type": "password", "user": "chris@vsphere.local", "password": "password" }' \ --inventory-file /etc/opt/mondoo/inventory.yml -
Scan using the vault (run as
root, since the vault lives in/etc/opt/mondoo/vault.enc):sudo cnspec scan --inventory-file /etc/opt/mondoo/inventory.yml systemctl restart cnspec
Next steps
Last updated on