Disable SSH

Time for another simple workflow. This time I needed to disable SSH on every host in a group of vCenters.

The basic idea is to loop through a list of vCenters, grab the hosts and then loop through each one of those and disable/stop SSH if needed.

Getting the hosts from a vCenter object is easy, all you do is call the getAllHostSystems function with two null’s as parameters (since we are not worried about filtering the results).

var hosts = vCenter.getAllHostSystems(null, null);

Once you have the list of hosts you loop through that list and get the services for each one of them.

for each ( var service in host.configManager.serviceSystem.serviceInfo.service )

Then you check the names of each service and if it matches the one you want to work with.

if( service.key == ‘TSM-SSH’ )

Now that you have the service object you can check the status of it.

if( service.policy != ‘off’ )
or
if( service.running )

Based on what you get back from that you can now stop the service or change the startup config of it as needed.

host.configManager.serviceSystem.updateServicePolicy(‘TSM-SSH’, ‘off’);
host.configManager.serviceSystem.stopService(‘TSM-SSH’);

To find the service name to look for you can open the VI client and go to the Security Profile and click on Properties for the service you are looking to work with and look at what the title bar of the dialog box says.

Pretty simple workflow, but maybe you can use some of this information in some other workflow you are working on.

Here is the completed action:

Download the workflow here.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">