1

I think I have locked myself out of my VM. I have access as a low priv user I have created but the user can't sudo.

When I do SSH->Open in browser window I get a promp asking for a password which I have never set.

Any way to reset root password from the GCP Console?

Thanks, Pavel

Pavel G
  • 21
  • 1
  • 2

2 Answers2

0

To reset a root password for your GCP VM you need to grant appropriate IAM roles to your user to use sudo command. There is a similar post here. You can use the command 'sudo passwd' to change the password as suggested in that post.

karel
  • 5,489
  • 46
  • 45
  • 50
Kamelia Y
  • 130
  • 5
0

Answering yout question you could simple run sudo commands using a startup script as the script would run as a root user, and then add your user in sudoers with sudo usermod -aG sudo, reference.

However, you could add a IAM role to your user in order to have admin access to a GCE VM, for example the roles/compute.instanceAdmin.v1, reference.

Toni
  • 1,054
  • 7
  • 12