Get root password for Google Cloud Engine VM
Figured it out. The VM's in cloud engine don't come with a root password setup by default so you'll first need to change the password using
sudo passwd
If you do everything correctly, it should do something like this:
user@server[~]# sudo passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
This work at least in the Debian Jessie image hosted by Google:
The way to enable to switch from you regular to the root user (AKA “super user”) after authentificating with your Google Computer Engine (GCE) User in the local environment (your Linux server in GCE) is pretty straight forward, in fact it just involves just one command to enable it and another every time to use it:
$ sudo passwd
Enter the new UNIX password: <your new root password>
Retype the new UNIX password: <your new root password>
passwd: password updated successfully
After executing the previous command and once logged with your GCE User you will be able to switch to root anytime by just entering the following command:
$ su
Password: <your newly created root password>
root@intance:/#
As we say in economics “caveat emptor” or buyer be aware: Using the root user is far from a best practice in system’s administration. Using it can be the cause a lot of trouble, from wiping everything in your drives and boot disks without a hiccup to many other nasty stuff that would be laborious to backtrack, troubleshoot and rebuilt. On the other hand, I have never met a SysAdmin that doesn’t think he knows better and root more than he should.
REMEMBER: We humans are programmed in such a way that given enough time at one at some point or another are going to press enter without taking into account that we have escalated to root and I can assure you that it will great source of pain, regret and extra work. PLEASE USE ROOT PRIVILEGES SPARSELY AND WITH EXTREME CARE.
Having said all the boring stuff, Have fun, live on the edge, life is short, you only get to live it once, the more you break the more you learn.
I had the same problem. Even after updating the password using sudo passwd it was not working. I had to give "multiple" roles for my user through IAM & Admin Refer Screen Shot on IAM & Admin screen of google cloud
After that i restarted the VM. Then again changed the password and then it worked.
user1@sap-hanaexpress-public-1-vm:~> sudo passwd
New password:
Retype new password:
passwd: password updated successfully
user1@sap-hanaexpress-public-1-vm:~> su
Password:
sap-hanaexpress-public-1-vm:/home/user1 # whoami
root
sap-hanaexpress-public-1-vm:/home/user1 #