How to Reset the Remote Password of a Linux Cloud Server?

15-01-2024 02:18:53

This article is applicable for scenarios where the remote password for the Linux operating system is forgotten and needs to be reset through a special method using the console. Some Linux cloud servers provide an online feature to reset the remote password, eliminating the need for this approach. If you need to change the password and remember the original one, you can remotely log in and modify the administrator password.

To begin, log into the Management Center. Navigate to Business Management => Cloud Server Management => Click on the specific cloud server => Console. Launch the console page. Then, click on “Send CtrlAltDel” in the top right corner of the console to reboot the cloud server. Alternatively, you can execute the restart within the Cloud Server Management.

Directory

CentOS 8

Return to Directory

1.When the GRUB version selection interface appears, immediately press the Esc key. Otherwise, the system will continue to boot, preventing further steps.

2.Select the first kernel and press 'e' to enter the editing interface.

3.Locate the line starting with the word 'linux', change 'ro' in this line to 'rw init=/sysroot/bin/sh'. Then press Ctrl+X to start the system in single-user mode.

4.After the system starts, enter 'chroot /sysroot' to access the system.

5.Use the 'passwd' command to reset the password.

6.Relabel the file system, then exit and restart the system.

touch /.autorelabel
exit
logout
reboot

7.After the system boots up normally, you can successfully log in with the new password.

CentOS 7

Return to Directory

1.The first 5 steps are identical to the password reset process for CentOS 8, with only differences in the kernel file content.

2.After resetting the password, enter 'reboot -f' to forcibly restart the system.

3.Once the system boots up normally, you can log in successfully with the new password.

CentOS 6

Return to Directory

1.When the "Booting CentOS..." prompt appears, immediately press any key to enter the kernel selection interface. Otherwise, the system will continue to boot, preventing further steps.

2.Select the first kernel and press 'a' to prepare to modify the kernel parameters.

3.At the end of the line, enter 'single' and press Enter.

4.After the system starts, use the 'passwd' command to reset the password, and then restart.

5.Once the system boots up normally, you can log in successfully with the new password.

Ubuntu

Return to Directory

1.During the system startup process, immediately press the Esc key to enter the kernel selection interface. Otherwise, the system will continue to boot, preventing further steps.

2.Select the first kernel and press 'e' to enter the editing interface.

3.Find the line starting with 'linux' and add 'init=/sysroot/bin/sh' at the end. Then press Ctrl+X to start the system in single-user mode.

4.After the system starts, enter 'mount -o remount,rw /' to remount the system.

5.Use the 'passwd' command to reset the password, followed by a forced restart.

6.Once the system boots up normally, you can log in successfully with the new password.

Debian

Return to Directory

1When the GRUB version selection interfaceappears, immediately press the Esc key. Otherwise, the system will continue to boot, preventing further steps.

2.Select the first kernel, then press the 'e' key to enter the editing interface.

3.Locate the line starting with 'linux', and change 'ro' in this line to 'rw init=/sysroot/bin/sh'. Then press Ctrl+X to boot the system in single-user mode.

4.After the system boots, enter 'chroot /sysroot' to access the system.

5.Use the 'passwd' command to reset the password.

6.Perform a relabel of the file system, then exit and restart the system.

Fedora

Return to Directory

1.When the GRUB version selection screen appears, immediately press the Esc key. Otherwise, the system will continue to boot, preventing you from proceeding to the next step.

2.Select the first kernel and press the 'e' key to enter the edit interface.

3.Locate the line where the first word is 'linux', and change 'ro' in this line to 'rw init=/sysroot/bin/sh'. Then, press Ctrl+X to start the system in single-user mode.

4.After the system starts, enter 'chroot /sysroot' to access the system.

5.Use the 'passwd' command to reset the password.

6.Perform a relabeling of the file system, then exit and restart the system.

touch /.autorelabel
exit
logout
reboot

7.After the system starts normally, you should be able to successfully log in using the new password.

FreeBSD

Return to Directory

1.When the system boot screen appears, press the '2' key to enter single-user mode.

2.Use the 'passwd' command to reset the password, and then restart.

3.After the system starts normally, you should be able to successfully log in using the new password.