VMware Cloud Community
drivera01
Enthusiast
Enthusiast
Jump to solution

ESXi - Enable/disable SSH

Hi,

Is there a way to enable/disable SSH (security settings). By default I have it disabled so no remote connection can be done over ssh. There are times when I do have to jump on take a quick peek though so I am wanting to get away from having to use vcenter.

I am not talking about "lockdown mode"

thanks

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You mean something like this ?

    Get-VMHost | Get-VMHostService |
   
where {$_.Key -eq "TSM-SSH"} |
    Start-VMHostService -Confirm:$false

Or this

Get-VmHost | %{
  $_.ExtensionData.ExitLockdownMode()
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

You mean something like this ?

    Get-VMHost | Get-VMHostService |
   
where {$_.Key -eq "TSM-SSH"} |
    Start-VMHostService -Confirm:$false

Or this

Get-VmHost | %{
  $_.ExtensionData.ExitLockdownMode()
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
drivera01
Enthusiast
Enthusiast
Jump to solution

As always... perfect LucD

thank you!!!

0 Kudos
Uday1990
Contributor
Contributor
Jump to solution

Hi,

 

How we can set "Start and stop with host" in this script for a cluster.

 

Thanks

0 Kudos
LucD
Leadership
Leadership
Jump to solution

With the Set-VMHostService cmdlet.
Loop through all nodes in the cluster


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Uday1990
Contributor
Contributor
Jump to solution

Hi,

 

I am using below script. Is it correct for a cluster ?

 

$Cluster = "Cluster Name"
$VMHost = Get-Cluster -Name $Cluster | Get-VMhost
ForEach ($VMhost in $Cluster){
Write-Host -ForegroundColor GREEN "Starting SSH Service on " -NoNewline
Write-Host -ForegroundColor YELLOW "$VMhost"
Get-VMHost | Get-VMHostService | ? {($_.Key -eq "TSM-ssh") -and ($_.Running -eq $False)} | Start-VMHostService
}
ForEach ($VMhost in $Cluster){
Write-Host -ForegroundColor GREEN "Setting Startup Policy on " -NoNewline
Write-Host -ForegroundColor YELLOW "$VMhost"
Get-VMHost | Get-VMHostService | where { $_.key -eq "TSM-SSH" } | Set-VMHostService -Policy "On" -Confirm:$false -ea 1
}
ForEach ($VMhost in $Cluster){
Write-Host -ForegroundColor GREEN "Setting UserVar to supress Shell warning on " -NoNewline
Write-Host -ForegroundColor YELLOW "$VMhost"
Get-VMhost | Get-AdvancedSetting | Where {$_.Name -eq "UserVars.SuppressShellWarning"} | Set-AdvancedSetting -Value "1" -Confirm:$false
}

 

Thanks

0 Kudos