Headless VMware Workstation: Running VMs in Background Mode for SSH Access


3 views

Many developers working with VMware Workstation often need to run virtual machines without the graphical interface, particularly for server environments or automated testing scenarios. The standard VMware GUI console becomes unnecessary overhead when you only require SSH access to the VM.

VMware Workstation Pro provides command-line options through the vmrun utility. Here's how to start a VM in headless mode:

vmrun -T ws start "C:\path\to\your\vm.vmx" nogui

For Linux/macOS systems:

vmrun -T ws start "/path/to/your/vm.vmx" nogui

Create a batch script (Windows) or shell script (Linux/macOS) to automate the process. Here's a Windows example:

@echo off
set VM_PATH="C:\VMs\ubuntu_server\ubuntu_server.vmx"
"C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" -T ws start %VM_PATH% nogui

Check if your VM is running properly in headless mode:

vmrun list

This will display all running VMs and their paths.

Before running headless, ensure your VM has SSH server installed and running at startup. For Ubuntu/Debian:

sudo apt update
sudo apt install openssh-server
sudo systemctl enable ssh

For CentOS/RHEL:

sudo yum install openssh-server
sudo systemctl enable sshd

For production environments, you might want VMs to start automatically with the host system. Create a scheduled task (Windows) or systemd service (Linux):

Windows Task Scheduler command:

schtasks /create /tn "StartVM" /tr "\"C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe\" -T ws start \"C:\VMs\vm.vmx\" nogui" /sc onstart /ru System

If your VM isn't starting properly in headless mode:

  • Verify VMware Tools is installed in the guest OS
  • Check the VM's log file for errors
  • Ensure the .vmx file path is correct
  • Try running vmrun as administrator

If you're using VMware Player (the free version), the command differs slightly:

vmrun -T player start "vm.vmx" nogui

Running VMware Workstation virtual machines without the GUI console (headless mode) is a common requirement for server administration, automated testing, and development workflows. The headless approach saves system resources and enables remote management via SSH.

The most straightforward method uses VMware's command-line interface:

vmrun -T ws start "C:\path\to\vm.vmx" nogui

Key parameters:

  • -T ws specifies VMware Workstation
  • nogui launches without the console window

Using VMware VIX API

import pyvmomi
from pyVmomi import vim

si = connect.SmartConnect(host="localhost", user="user", pwd="password")
vm = si.content.searchIndex.FindByInventoryPath("path/to/vm")
task = vm.PowerOnVM_Task()
WaitForTask(task)

Scheduled Task Approach

Create a Windows scheduled task or Linux cron job to execute:

vmrun start "vm_path.vmx" nogui

Check running VMs and their IP addresses:

vmrun list
vmrun getGuestIPAddress "vm.vmx" -wait
  • Ensure VMware Tools is installed in the guest OS
  • Verify network adapter is set to bridged/NAT mode
  • Check firewall settings allow SSH connections