NSX | How to disable SSH on all NSX edges?

Enabled SSH can be a security threat so it is recommended to keep it disabled and enable only when highly required.

Again disabling it manually is a tedious task (at least for me) so I thought to do it through powershell.

Below example is for selected edges, in case you want it to run for all then simply remove the source file and run "Get-Nsxedge". 

To disable SSH on selected Edges
#Connect NSX Manager and replace with actual IP address of NSX Manager
Connect-NsxServer -nsxserver
#put a file with edge-ID in below location. In case you want to disable on selected edges
foreach($edgelist in (Get-Content -Path C:\TEMP\edgelist.txt)){
#below command will disable ssh on all the mentioned edges in above .txt file 
Get-NsxEdge -objectId $edgelist | Disable-NsxEdgeSsh -Confirm:$false
#Let's cross check the status after disabling it
$ssh = Get-NsxEdge -objectId $edgelist

To disable SSH on all NSX edges.
 Connect-NsxServer -nsxserver
 Get-NsxEdge  | Disable-NsxEdgeSsh -Confirm:$false

Any query? Feel free to ask.

Thank you,
Team vCloudNotes


Post a Comment