1
votes

I am using pyVmomi for my automation. Now I am testing a VM, where the SSH is disabled by default, and I must change the password upon the first login:

You are required to change your password immediately (root enforced)

If I try connecting using pyVmomi's StartProgramInGuest, I get vim.fault.InvalidGuestLogin exception:

Failed to authenticate with the guest operating system using the supplied credentials

I am looking for a way to change the default password programmatically, (preferably) using pyVmomi

1
As far as looking at the error, it seems a login to a guest error by user or password mistake. Do you have not wrong with the user and password for a guest?sky_jokerxx
The credentials are fine. I think vmware doesn't have this type of an error. It is too specific.Arik

1 Answers

0
votes

To start off, it seems like you failed to pass the correct credentials when calling the "StartProgramInGuest" function, you can specify and pass credentials to this function using Name-Password authentication, like below.

creds = vim.vm.guest.NamePasswordAuthentication(username='username', password='password)

Test this and make sure you successfully authenticated to the guest virtual machine. After you're able to successfully authenticate, you can use Process Manager, to create either a Linux process or Windows process to change your password. For example, here is a PowerShell process tested on a Windows 10 virtual machine, executed through StartProgramInGuest.

 argument= vim.vm.guest.ProcessManager.ProgramSpec(programPath='powershell.exe -Command', arguments='"& {net user  loginid  newpassword;}"')
 res = pm.StartProgramInGuest(vm, creds, argument)

Let me know if you need any clarification!