PowerCLI

 View Only
  • 1.  Can we change -> SSH config value -> "permitrootlogin=yes" - via "Power CLI"??

    Posted Sep 17, 2012 03:55 PM

    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



  • 2.  RE: Can we change -> SSH config value -> "permitrootlogin=yes" - via "Power CLI"??

    Posted Sep 17, 2012 04:09 PM

    Yeah.. it requires to modify /etc/ssh/sshd_config --> file

    and "Service sshd restart" also..

    Do I have "excess expectation" via "PowerCLI" :-)  ???



  • 3.  RE: Can we change -> SSH config value -> "permitrootlogin=yes" - via "Power CLI"??

    Posted Sep 17, 2012 04:20 PM

    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 :-)



  • 4.  RE: Can we change -> SSH config value -> "permitrootlogin=yes" - via "Power CLI"??

    Posted Sep 17, 2012 04:48 PM

    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.



  • 5.  RE: Can we change -> SSH config value -> "permitrootlogin=yes" - via "Power CLI"??

    Posted Sep 17, 2012 05:18 PM

    Hmm.. Confused with that.. :-)

    Please provide "Power Shell Example command" - if you can..

    which can change to --> "PermitRootLogin=yes"



  • 6.  RE: Can we change -> SSH config value -> "permitrootlogin=yes" - via "Power CLI"??

    Posted Sep 17, 2012 05:41 PM

    Are you using ESX or ESXi ?



  • 7.  RE: Can we change -> SSH config value -> "permitrootlogin=yes" - via "Power CLI"??

    Posted Sep 18, 2012 05:55 AM

    Hi,

    We need to do "PermitRootLogin-yes" on --> ESX5i  (via PowerCli 5.0)



  • 8.  RE: Can we change -> SSH config value -> "permitrootlogin=yes" - via "Power CLI"??

    Posted Sep 18, 2012 07:59 AM

    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#$%$%^^&*”  :smileywink:

    This should work., You can make a powershell function which is more customizable from this if you need.

    set-hostrootlogin "yourhost.yourdomain.local"

    :smileywink:

    Regards,

    Greg