# Fix: Reset Expired ESXi 8 Evaluation License via SSH

## Environment
- VMware ESXi 8 (two hosts)
- License: Evaluation mode (60-day trial expired)

## Problem

ESXi evaluation period expired. The web UI shows license warnings and functionality is restricted. VMs may not auto-start after host reboots.

```
vim-cmd vimsvc/license --show
# diagnostic = Evaluation period has expired, please install license.
# expirationHours = 0
# expirationMinutes = 0
```

## Fix

### Step 1: Enable SSH (if not already)
In ESXi web UI: **Host** → **Actions** → **Services** → **Enable SSH**

### Step 2: SSH in and Reset

```bash
ssh root@<esxi-host-ip>

# Remove current license config and restore default
rm -r /etc/vmware/license.cfg
cp /etc/vmware/.#license.cfg /etc/vmware/license.cfg

# Restart services to pick up the change
/etc/init.d/vpxa restart
/etc/init.d/hostd restart
```

**Note:** After restarting hostd, the web UI will be unavailable for 15-30 seconds while it comes back up.

### Step 3: Verify

Wait ~15 seconds for hostd to fully start, then:

```bash
vim-cmd vimsvc/license --show
```

Expected output:
```
serial: 00000-00000-00000-00000-00000
vmodl key: eval
name: Evaluation Mode
total: 1
used: 1
[evaluation] = License has not been set, evaluation Period in effect.
[expirationHours] = 1440
[expirationMinutes] = 0
[expirationDate] = <60 days from now>
```

## Automation via Expect (for remote execution)

If you need to script this from a Linux workstation and `sshpass` doesn't work with ESXi's keyboard-interactive auth (common issue), use `expect`:

```bash
# Install expect (Arch)
sudo pacman -S expect

# Run reset
expect -c '
spawn ssh -o StrictHostKeyChecking=no -o PubkeyAuthentication=no root@192.168.0.122 \
  "rm -r /etc/vmware/license.cfg && cp /etc/vmware/.#license.cfg /etc/vmware/license.cfg && /etc/init.d/vpxa restart && /etc/init.d/hostd restart"
expect "Password:"
send "your_password_here\r"
expect eof
'
```

**Note on sshpass:** ESXi 8 uses `keyboard-interactive` authentication, not `password` auth. `sshpass` fails with exit code 5 even with correct credentials. `expect` handles keyboard-interactive properly.

## Important Notes

- This resets the 60-day evaluation timer — it does not provide a permanent license
- The reset can be repeated when the evaluation expires again
- VMs configured to auto-start should resume normal operation after the license is active
- If you have a legitimate license key, apply it via the web UI instead: **Manage** → **Licensing** → **Assign license**
