Here is a new video inspired by Alan Renouf's post.
Well I wanted to test Alan's post on starting SSH service on your ESXi 4.1 host remotely via PowerCLI. And as you know, picture (video) is worth a thousand words…. I've done a video of that. Now, I'm not a scripting guy.. not at all. But as you'll see, powerCLI is quite easy to learn, and easy to manipulate with copy-paste ready code…. everyone can do it.
As you already know, there are several ways to activate SSH on your ESXi 4.1 server. In the GUI or on the console of the server. So right now I knew that it was possible to handle this task in 2 ways. But for the security is best to leave the service stopped and activate it only when needed.
You can activate SSH on ESXi 4.1 already in 3 ways now:
01. Through the GUI – just selest the host in your VI client and go to Configuration TAB > Security profile > properties.
02. Do it at the server console – You can do it on the console, but you must be in front of the server.
Press F2 and enter your root password > scroll down to Troubleshooting options and hit Enter > Enable/disable the Remote tech support – SSH
03. PowerCLI option – Yes you can do it through PowerCLI now. As I saw the Alan Renouf's article on his blog, I did a little video to document that on my website. See the original Article on Alan's blog here.
You'll basically need this one line of code to start the service:
Get-VMHost | Foreach { Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq “TSM-SSH”} )}
There is even possibility to check all your ESX hosts in your datacenter and see which one is running SSH service or not. You can do it with this line of code:
Get-VMHost | Get-VMHostService | Where { $_.Key -eq “TSM-SSH” } |select VMHost, Label, Running
And here is my video as I could test it is working. Enjoy.
Source: Virtu-Al
Alan Renouf says
Thanks for the mention.
Vladan SEGET says
No problem Alan. -:)
martin says
I have never done a lot of scripting before, but this one worked for me on first try. I will have more deep look into power cli as I can see it is great tool, mainly if you cannot seat by the server and use cli.
JC says
Hi VLadan, I might posting at the wrong place but maybe you can guide me to the right place. I was woundering if is possible to applied a simple user account to all my VMhost through POWERCLI simultaneously? I’ve done this through Putty one at the time, but I was woundering if is possible to script something like this and push to multiple host.
Thanks,