We have "Large Number of ESX & ESXi" hosts (But "PermitRoonLogin=No" in /etc/ssh/sshd_config)
Any idea, can we change all hosts to --> PermitRootLogin --> YES --> via Power CLI
Thank you in advance..
Regards - Purna
Yeah.. it requires to modify /etc/ssh/sshd_config --> file
and "Service sshd restart" also..
Do I have "excess expectation" via "PowerCLI" 🙂 ???
http://communities.vmware.com/message/1228094
As per LucD -> SSH Service can be restarted via -> Start-VmHostService "cmdlet"
--> Get-VmHostService -VMHost $vmhost | Where-Object {$_.key -eq "TSM-SSH"} | Start-VMHostService
Now all I need is -> How to modifiy "PermitRootLogin=yes" -> in "/etc/ssh/sshd_config" ??? (Currently it is "no")
Curious 🙂
With ESX you can edit that file via SSH.
With ESXi it's a bit more tricky and most probably not supported.
In the PowerCLI Reference book we showed a way of doing this through the Get-VMHostFirmware and Set-VMHostFirmware cmdlets.
And don't forget that you have to make sure that your change survives a reboot.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hmm.. Confused with that.. 🙂
Please provide "Power Shell Example command" - if you can..
which can change to --> "PermitRootLogin=yes"
Are you using ESX or ESXi ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
We need to do "PermitRootLogin-yes" on --> ESX5i (via PowerCli 5.0)
Hi there,
i don't know the possibility in doing this directly from powershell. One way is to use plink.
function set-hostrootlogin([string]$esxentry){
$str1=’c:\plink.exe -v -pw ”v53HYfsd#$%$%^^&*” -l root ‘
$str2=’ sed -i "s/PermitRootLogin no/PermitRootLogin yes/g" /etc/ssh/sshd_config’
$esxhost=”‘”+$esxentry+”‘”
$command=$str1+$esxhost+$str2
$esxentry.name >> $outfile
Invoke-Expression -Command $command
}
assuming you have plink.exe in c:\ and password of -pw ”v53HYfsd#$%$%^^&*”
This should work., You can make a powershell function which is more customizable from this if you need.
set-hostrootlogin "yourhost.yourdomain.local"
Regards,
Greg