Created
January 15, 2019 13:39
-
-
Save vMarkusK/884d2efbb5824a2687523aeb627f2ad5 to your computer and use it in GitHub Desktop.
VMware ESXi Host Base Hardening
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach ($VMhost in (Get-VMHost)) | |
{ | |
#Stop SSH Service | |
$ServiceList = Get-VMHostService -VMhost $VMhost | |
$SSHservice = $ServiceList | Where-Object {$_.Key -eq "TSM-SSH"} | |
If ($SSHservice.Running -eq $true) {Stop-VMHostService -HostService $SSHService -Confirm:$false} | |
else {Write-Output "SSH Server on host $VMhost is Stopped"} | |
$Shellservice = $ServiceList | Where-Object {$_.Key -eq "TSM"} | |
If ($Shellservice.Running -eq $true) {Stop-VMHostService -HostService $Shellservice -Confirm:$false} | |
else {Write-Output "Shell Server on host $VMhost is Stopped"} | |
#Enable Shell Warning | |
$VMHost | Get-AdvancedSetting -Name UserVars.SuppressShellWarning | Set-AdvancedSetting -Value 0 -Confirm:$False | |
#Enable Lockdown Mode | |
$HostView = $VMHost | Get-VIEvent | |
if (($HostView).config.LockdownMode -eq "lockdownNormal"){ ($HostView).EnterLockdownMode()} | |
else {Write-Output "LockdownMode on host $VMhost is Enabled"} | |
#Set Timeouts | |
$VMHost | Get-AdvancedSetting -Name UserVars.ESXiShellInteractiveTimeOut | Set-AdvancedSetting -Value 900 -Confirm:$False | |
$VMHost | Get-AdvancedSetting -Name UserVars.ESXiShellTimeOut | Set-AdvancedSetting -Value 900 -Confirm:$False | |
$VMHost | Get-AdvancedSetting -Name Security.AccountLockFailures | Set-AdvancedSetting -Value 3 -Confirm:$False | |
$VMHost | Get-AdvancedSetting -Name UserVars.DcuiTimeOut | Set-AdvancedSetting -Value 600 -Confirm:$False | |
$VMHost | Get-AdvancedSetting -Name Security.AccountUnlockTime | Set-AdvancedSetting -Value 900 -Confirm:$False | |
#Enable BPDU filter | |
$VMHost | Get-AdvancedSetting -Name Net.BlockGuestBPDU | Set-AdvancedSetting -Value 1 -Confirm:$False | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment