Automation

 View Only
  • 1.  vmware cmdlet to access a vm and set an ssh credential

    Posted Apr 03, 2017 02:05 PM

    Hi all,

    I have been looking into doing some automation work and the first step for this to work is i need to be able to make sure ssh config are added onto a vm through vmware powershell (or cli interface)

    I was wondering if we have a set cmdlet command that would allow me to set the ssh username and password on a linux vm?

    Your help would be very much appreciated.

    Regards,

    Divesh.



  • 2.  RE: vmware cmdlet to access a vm and set an ssh credential

    Posted Apr 03, 2017 02:21 PM

    I'm not aware of a specific command.

    you can use 'invoke-vmscript' to run a command(or script) on a vm.



  • 3.  RE: vmware cmdlet to access a vm and set an ssh credential

    Posted Apr 03, 2017 10:46 PM

    Hi jpsider,

    Yeah after looking on the VMware site, it appears there isn't a cmdlet that would allow you to do that.

    I think a script would be required to achieve that.

    Does anyone have a script that allows you to access a Linux vm through powershell and configure it with either ssh or telnet. The idea is as soon as I have configured the vm with ssh/telnet, I would use an automated tool to log into the vm using ssh/telnet and do certain checks, perform certain actions (including AD integrate the vm) and then delete the temporary ssh/telnet credential that I originally created through powershell.

    Any advice/pointers/help would be much appreciated.

    Regards,

    D



  • 4.  RE: vmware cmdlet to access a vm and set an ssh credential

    Posted Apr 04, 2017 02:03 AM

    Not sure what flavor of Linux, but this will get you close, you'll need to create you own script and copy it to the Vm's like this

    Copy-VMGuestFile -Source "C:\temp\enablSSH.sh" -Destination "/LocalDropbox/enableSSH.sh" -LocalToGuest -vm $vmname -GuestUser $VMUN -GuestPassword $VMPW

    Then execute like

    Invoke-VMScript -ScriptText "/bin/bash /LocalDropbox/enableSSH.sh" -VM $vmname -GuestUser $VMUN -GuestPassword $VMPW -ErrorAction SilentlyContinue



  • 5.  RE: vmware cmdlet to access a vm and set an ssh credential

    Posted Apr 04, 2017 01:16 PM

    Hi jpspider,

    I have created a script and followed the procedure you mentioned. However, I am getting the following error message:

    Any idea why it is complaining that the script exist? It should be existing for me to run it isn't it?

    Also can I assume you do not need to make the script executable before using the invoke-VMscript cmdlet?

    Thanks.

    Regards,

    D



  • 6.  RE: vmware cmdlet to access a vm and set an ssh credential

    Posted Apr 04, 2017 07:19 PM

    hmmm, that is the output of the script you ran. It is not saying that the script itself exists.

    Can you post your script you created to enable ssh?



  • 7.  RE: vmware cmdlet to access a vm and set an ssh credential

    Posted Apr 05, 2017 08:21 AM

    Hi jpsider,

    Issue is now fixed and it's all working as expected now.

    This was not really the output of the script; I was getting the message because I called my script "adduser.sh" and since this is already a known Linux function, it was complaining. I changed the name and it worked!

    Thanks a lot for your input, much appreciated! :smileyhappy:



  • 8.  RE: vmware cmdlet to access a vm and set an ssh credential

    Posted Apr 05, 2017 08:26 PM

    -scripttype BASH

    May have helped.  Sorry!