Ok, I have been living under a rock a little recently, I have had so much going on that my blog and my hands on time has been suffering, sorry for that.
Whilst delivering a presentation on the new features in vSphere 4.1 – Of which there are tons (should have been 4.5 in my opinion), I came across the ability to be able to enable SSH from the DCUI (Direct Console User Interface).
This has also been made available as a service in vCenter now where they can be remotely started and stopped….
OK, so this is probably not new news for the people who have had time to play with 4.1 but the cool thing is that that this is now also available via PowerCLI too, we can see this if we retrieve the VMHost and then run a Get-VMHostService on it….
This is great news, so now if we needed to we could start the SSH service for each of our hosts with just a simple piece of code:
Get-VMHost | Foreach { Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} ) }
We can also do this for any of the other services in the list including restarting the vCenter Agent – Now that’s a cool new feature in 4.1 !
We can also list all of our hosts and see if the service is running using the following one-liner:
Get-VMHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH" } |select VMHost, Label, Running
Pingback: Start or stop ESXi services using PowerCLI - vConsultants blog
Pingback: Start or stop ESXi services using PowerCLI - vConsultants blog
Pingback: PowerCLI oneliners - vConsultants blog
Thank you so much for this best simple code. I tried to modify your code to start the service on the single host, but it is in vain. Much appreciated your help Alan.
Hello , Alan ,I like your “one line” script , haha ,Thanks.
I like your “one line” script , haha ,Thanks.
Pingback: 6 ways to enable SSH on an ESXi host | wintelvm
Pingback: List all physical QLogic HBA’s driver and firmware information of all your ESXi 4.1/5.0 hosts using PowerCLI 5.0.1 « Yuri's Technology Blog
Can I enable “PermitRootLogin=yes” –> via powercli –> Currently value is “PermitRootLogin=no”
–> at /etc/ssh/sshd_config
Thanks Mike, thats good to know.
I couldn’t get this script to work for me on ESXi 5. I think its because the service name has changed? Using “Get-VmHostService -VMHost esx03nj.corp.com” I found out the name of the service is “SSH”…
Changing the script to:
Get-VMHost | Foreach {
Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq “SSH”} )
}
Worked just fine.
Thanks Alan…
Pingback: Useful Powercli Stuff | VMwise
When I run the command to list all of the states, it gives the following output:
VMHost Label Running
—— —– ——-
Remote Tech Support (SSH) False
Remote Tech Support (SSH) False
Remote Tech Support (SSH) True
Remote Tech Support (SSH) True
Remote Tech Support (SSH) True
Remote Tech Support (SSH) True
Remote Tech Support (SSH) True
Remote Tech Support (SSH) False
I’m not sure why it won’t output the name of the host…
Pingback: VirtualClouds.info » 6 ways to enable SSH on an ESXi host
To bad after closing it, current sessions are not killed.
Seems a security issue to me.
Good idea, now to find the time 🙂
Any plans to add control of the services to the Community Powerpack?
Not directly i dont think but you can run putty through powercli or other ssh clients.
Hi,
Are you able to enable the webAccess service also with the PSCLI?
Aleksandar, yes you are right, that is an easier way to do it 😉
Code for starting the SSH service on all of our VM hosts can be simpler:
Get-VMHost | Get-VMHostService | Where { $_.Key -eq “TSM-SSH”} | Start-VMHostService
Pingback: Tweets that mention Enabling ESX SSH via PowerCLI | Virtu-Al -- Topsy.com