Table of Contents
In this article, we will look into how to get the root password for Google Cloud Engine VM. Sometimes when you are working with the Google Cloud VM and you need to perform some privileged tasks which cannot be done through non-root user then you can either request for sudo access or root access. Here we will keep our focus on root access. To run any command with root access you need to know the root password. gcloud VM does not come with a default root password so you probably need to manually set the password. This can be easily done by using below mentioned steps.
How to Get the Root Password for Google Cloud Engine VM
Also Read: How to Upload Files to Google gcloud VM Instance Using 3 Easy Steps
Step 1: Prerequisites
a) You should have valid Google Email ID
and Password
.
b) Google Cloud Engine VM should be accessible.
c) You should have necessary IAM Access to reset the password.
Step 2: Reset the Root Password
To reset the root password, you need to run sudo passwd command as you can see below. Here you need to provide a new password and then confirm it again by retyping the same password.
cyberithub@cloudshell:~/sample-project-repo (sample-project-308612)$ sudo passwd New password: Retype new password: passwd: password updated successfully
Step 3: Login with Root User
Once password reset is done, you can try to login as root user by using su -
command as shown below. This command will prompt for the root
password. Once you provide the correct password, you will be logged in successfully.
NOTE:
root
password will get discontinued and you may need to reset again to login as a root
user.cyberithub@cloudshell:~ (sample-project-308612)$ su - Password: Welcome to Cloud Shell! Type "help" to get started. To set your Cloud Platform project in this session use “gcloud config set project [PROJECT_ID]”
You can use id
command to verify the logged in user as you can see from below output. More on Managing Instance Access.
root@cloudshell:~$ id uid=0(root) gid=0(root) groups=0(root)