vmware-archive / powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
173 stars 90 forks source link

Disable SSH on NSX Edge and SSH Manager #588

Closed michaelshaoul closed 5 years ago

michaelshaoul commented 5 years ago

need powercli or powernsx method to disable SSH in NSX Manager appliance and NSX Edge stop-Service -Name ssh-agent , didn't give an error but didn't stop services either

alagoutte commented 5 years ago

There is no yet PowerNSX for disable SSH for NSX Manager (may be need to look via CLI option)

for NSX-Edge, you can use


Get-NsxEdge Edge01 | Disable-NsxEdgeSsh`
michaelshaoul commented 5 years ago

works

alagoutte commented 5 years ago

For Manager, there is no yet dedicated cmdlet, but you can use

PS > (Invoke-NsxRestMethod -uri "/api/1.0/appliance-management/components/component/ssh"-method "get").component

componentId         : SSH
name                : SSH Service
description         : Secure Shell
status              : RUNNING
enabled             : true
showTechSupportLogs : false
usedBy              :
componentGroup      : SYSTEM

PS > (Invoke-NsxRestMethod -uri "/api/1.0/appliance-management/components/component/ssh/toggleStatus/stop" -method "post").result

result operationStatus
------ ---------------
result SUCCESS

PS > (Invoke-NsxRestMethod -uri "/api/1.0/appliance-management/components/component/ssh"-method "get").component

componentId         : SSH
name                : SSH Service
description         : Secure Shell
status              : STOPPED
enabled             : true
showTechSupportLogs : false
usedBy              :
componentGroup      : SYSTEM

use

 PS > (Invoke-NsxRestMethod -uri "/api/1.0/appliance-management/components/component/ssh/toggleStatus/start" -method "post").result

for start the composent/service

michaelshaoul commented 5 years ago

Do you know if there is a Invoke-NsxRestMethod for the Edge as well as the appliance ?

alagoutte commented 5 years ago

There is already Enable-NsxEdgeSsh / Disabled-NsxEdgeSsh

but if you really need the URI, it is :

$URI = "/api/4.0/edges/$($Edge.Edgesummary.ObjectId)/cliremoteaccess?enable=false"

$Edge.Edgesummary.ObjectId is Edge ObjectId (can be found via (Get-nsxEdge Edge01).edgeSummary )

michaelshaoul commented 5 years ago

Hello Alexis,

Sorry to bother, however the repository "vCheckReport/vCheck-NSX" has a pluggin 155 for backup check. It is missing a function or something. Do you know how I would find it ?

thanks

Mike


From: Alexis La Goutte notifications@github.com Sent: 31 July 2019 14:43 To: vmware/powernsx powernsx@noreply.github.com Cc: michaelshaoul michael.shaoul@outlook.com; State change state_change@noreply.github.com Subject: Re: [vmware/powernsx] Disable SSH on NSX Edge and SSH Manager (#588)

There is already Enable-NsxEdgeSsh / Disabled-NsxEdgeSsh

but if you really need the URI, it is :

$URI = "/api/4.0/edges/$($Edge.Edgesummary.ObjectId)/cliremoteaccess?enable=false"

$Edge.Edgesummary.ObjectId is Edge ObjectId (can be found via (Get-nsxEdge Edge01).edgeSummary )

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/vmware/powernsx/issues/588?email_source=notifications&email_token=AMSLTRSUHXURMN2NRFICHKDQCGJJTA5CNFSM4H7MYUU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3HJJOQ#issuecomment-516854970, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMSLTRQKJSZA3YXVY5BDN4LQCGJJTANCNFSM4H7MYUUQ.

michaelshaoul commented 5 years ago

thanks for your help with ssh, new issue opened for vchecknsx pluggin issue