Powercli라는 좋은 툴이 있는건 알았다.
그런데 사용법이?!
현재 필요항 항목부터 한개씩 누적해서 적어본다.
"서비스" 항목 중 TSM-SSH Start
Get-VMHost | Get-VMHostService | where {$_.Key -eq "TSM-SSH"} | Start-VMHostService
"방화벽" 설정에서 sshServer 접근제어 모두허용 해제
이걸 Powercli에서 못찾아서 헤메는 중
esxcli에서 수행하면 가능은 한데 실행하는 순간 연결이 끊겨버림... 접근제어 대상 추가해야 하는데 이게 켜져 있으면 입력이 안됨 ㅋㅋㅋㅋ
esxcli network firewall ruleset set --allowed-all false --ruleset-id=sshServer
접근제어 대상 추가하려면(물론 안되지만 ㅠ)
esxcli network firewall ruleset allowedip add --ip-address=X.X.X.0/24,X.X.X.0/24 --ruleset-id=sshServer
인터넷에서 찾은건데
Firewall sshServer 모두접근 해제는 되는데 예외 IP 설정은 안된다.
$cluster = "<clusterName>"
$ip = "192.168.1.1"
foreach($vmHost in (Get-Cluster $cluster | Get-VMHost | Sort Name)){
write-host "Configuring SSH on host: $($vmHost.Name)" -fore Yellow
if((Get-VMHostService -VMHost $vmHost | where {$_.Key -eq "TSM-SSH"}).Policy -ne "on"){
Write-Host "Setting SSH service policy to automatic on $($vmHost.Name)"
Get-VMHostService -VMHost $vmHost | where { $_.key -eq "TSM-SSH" } | Set-VMHostService -Policy "On" -Confirm:$false -ea 1 | Out-null
}
if((Get-VMHostService -VMHost $vmHost | where {$_.Key -eq "TSM-SSH"}).Running -ne $true){
Write-Host "Starting SSH service on $($vmHost.Name)"
Start-VMHostService -HostService (Get-VMHost $vmHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"}) | Out-null
}
$esxcli = Get-EsxCli -VMHost $vmHost
if($esxcli -ne $null){
if(($esxcli.network.firewall.ruleset.allowedip.list("sshServer") | select AllowedIPAddresses).AllowedIPAddresses -eq "All"){
Write-Host "Changing the sshServer firewall configuration"
$esxcli.network.firewall.ruleset.set($false, $true, "sshServer")
$esxcli.network.firewall.ruleset.allowedip.add("$ip", "sshServer")
$esxcli.network.firewall.refresh()
}
}
if(($vmHost | Get-AdvancedSetting | Where {$_.Name -eq "UserVars.SuppressShellWarning"}).Value -ne "1"){
Write-Host "Suppress the SSH warning message"
$vmHost | Get-AdvancedSetting | Where {$_.Name -eq "UserVars.SuppressShellWarning"} | Set-AdvancedSetting -Value "1" -Confirm:$false | Out-null
}
}
'VMware' 카테고리의 다른 글
Powercli로 VM에 RDM 추가 및 삭제 (0) | 2022.11.28 |
---|---|
Storage I/O Control 리소스 공유 및 제한 설정 (0) | 2022.11.25 |
Powercli 로 고급 설정 일괄 변경 (0) | 2022.11.11 |
Snapshot Datastore가 인식되지 않을 때 (0) | 2022.11.08 |
How to delete event "The number of boot attempts has been exceeded"? (0) | 2022.11.08 |
댓글