Search code examples
linuxubuntugoogle-cloud-platformsshgoogle-compute-engine

SSH: How to know the password of sudo users created automatically by gcloud?


I am able to connect to my instance using the normal SSH button and gcloud command. These two connection methods created @<myusername> and @<myusername_gmail_com> user accounts respectively

The problem is I don't know the password for either of these users.
This became apparent when I

sudo adduser git
sudo su git

created and switched to a new user to setup git access, I know the password for this user because I created it like normal

now switching back to the default sudo user

sudo su <myusername>

asks for a password

I tried my <Google account password>, "", "admin" — and then gave up.
At no point did I define a password for this account when it was created by gcloud.

So after switching to the git user the only way I was able to switch back to default sudo user was to kill the session and restart it.


Solution

    1. You can change the passport by first elevating to root user:

    sudo su -

    1. Then change the password for the user in question:

    passwd mysername