Is there any solution to gain access of the password of user account in VM instance in Google Cloud Platform

I'm using the VM compute engine service Of GCP, in which I have created a instance of Ubuntu-pro but when I go to terminal for like sudo command it ask me the password every time for the user account but my question is that I have not set any password yet but its asking again and again. So how I can know the password of user account in ubuntu vm instance


There are no password on GCP linux VM by default, you will need to manually set it up. To do that, follow the steps below:

  1. Open SSH Connection to VM.
  2. Type sudo su (to switch to root user)
  3. Type sudo passwd (to create password for root user) The result should look like this:
New password:
Retype new password:
passwd: password updated successfully
  1. Type whoami (to verify the user)

Linux accounts in GCP use SSH keys instead of passwords, so you don't have a password by default.
Your user account isn't in the google-sudoers group, which is in sudoers with NOPASSWD:ALL set.
It's possible that the VM hasn't finished running the startup script for some reason, I saw that enough times to write a wiki page at a previous job. Check the serial port 1 log for errors, especially google-startup-scripts.service.
It's also possible that your Google account doesn't have the roles/compute.osAdminLogin permission, which would explain why you aren't allowed to sudo without a password. If that's the case then you can add this to the startup script to force adding it:

useradd -G google-sudoers account_name

Though getting the roles/compute.osAdminLogin permission would give you access without rebooting the VM.