Google Cloud does not provide its users with the sudo password and some applications do require us to enter the root password to install dependencies. It will just take us to enter a few commands to gain root access and change or update the root password or our Google Cloud VM.
How to get the root password of Google Cloud VM?
Here I will show you how to reset the root password of a Google Cloud virtual machine that is running the Ubuntu operating system. For other Linux based operating systems, the process and commands are pretty similar.
- SSH into your VM using the option on the Google Cloud console.
- It will automatically log you in with your default cloud account.
- We will now log in as sudo by entering
$ sudo su root
- Now enter ‘cd ..’ twice separately in different lines, leading you to the root directory.
- Now set your root password by entering
$ passwd root
- Confirm the password by entering it twice as asked and now we will edit the sshd_config file.
- Start editing the sshd_config file with nano by entering
nano /etc/ssh/sshd_config
- Look for ‘PERMITROOTLOGIN‘ and change it from ‘no’ to ‘yes’ and change ‘PASSAUTHENTICATION ‘ to ‘yes’.
- Now restart the ssh service.
service sshd restart
Done now you have successfully reset your root password and can use it to log in to your VM.
Summary
Article Name
How to get root password in Google Cloud VM?
Description
Learn how to change the root password on a VM in Google Cloud.
Author
Yash