Home > Software engineering >  SSH: How to know the password of sudo users created automatically by gcloud?
SSH: How to know the password of sudo users created automatically by gcloud?

Time:03-07

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.

CodePudding user response:

  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

CodePudding user response:

If you mean you want to know the root password for your SSH to your Ubuntu OS, there is no password set for it by default, unless it was a custom set up, as discussed by @John Hanely. Also, by default, compute engine service account will be assigned.

Be reminded that you should add your newly created account to sudoers if you want your account to have a root privileged.

You can add user in sudoers by accessing:

  1. Go to /etc, and find the sudoers file
cd /etc
  1. Access sudoers file, using vim or a text editor available to your system.
vim sudoers
  1. Once accessed you can now add your user, there are already instructions indicated on how you can add your user.

  2. After adding your user, save and exit to your text editor.

For vim:

wq!

Note: each text editor have different on how to exit.

  • Related