Reset Linux User Password on Google Cloud Computer
if your root password is fotget,You can reset it using the following method .
Description
Environment
- GCP security group allows 0.0.0.0/0 to access the SSH port;
- In the operating system, Firewall-cmd specifies the IP that can access the SSH port
- In the operating system, /etc/hosts.deny and /etc/hosts.allow are set
- Disable root user login
Failure
For some reason, all user passwords are lost and need to be reset.
Solution
- you need to shut down(Stop) the server.

-
click EDIT

-
Copy the following code to the Startup script.

#!/usr/bin/bash
echo 'USER:NEW-PASSWORD' | chpasswd # Pls replace USER:NEW-PASSWORD with the username and new password you want to reset.
mv /etc/hosts.allow /etc/hosts.allow.bak
mv /etc/hosts.deny /etc/hosts.deny.bak
systemctl disable firewalld
sed -i "s/PermitRootLogin no/PermitRootLogin yes/g" /etc/ssh/sshd_config
- Then, save and start the server, and you can log in to the server using the new password.