How to solve the problem of VPS forgetting password in CentOS system?


It’s not applicable to OpenVZ under the solusvm management panel or Xen, because you forget to reset root password directly under the background. However, if you are a stand-alone server or a KVM installation step by step, what if you forget? This article is to record solutions to similar problems.

A friend who used to use KVM asked Zhao Rong to forget the root password. Where can I change it? I would generally think that the system should be reinstalled Please forgive me for my ignorance. Reinstallation is not the best choice. We can easily reset the root password through VNC connection.

I’ll take any VPS to test. In this paper, I take centos5. * system as an example and test it on two KVM VPS. They are (Kansas) and (Singapore)

Suppose we forget the root password. First, log in to the solusvm management panel, and we will perform a reboot, and then connect VNC.

You can click the VNC button directly in the panel, or you can record the VNC information and use the tool. I will execute it directly in the background here.


Pay attention to the above step. If you restart, go to VNC immediately. The action is a little faster, because the Startup menu will be skipped soon. When you see the countdown as shown above, press the up and down arrow keys of the keyboard to select.

The following figure shows the currently optional system kernel. Select the line change and press “e” on the keyboard to edit.


As shown in the figure below, select the second line and press “e” to edit.


Add “space single” at the end of the line change, and note that a space is left between single and the previous section.

As shown in the picture below, I’ve framed it in red.


Enter to save after input and press “B” to start in single user mode.

At this time, the system logs in directly without entering any password, as shown below:


It’s simple here. We can set the root password at will, and directly command passwd or passwd root. Input the password that needs to be set twice in a row. After restarting the machine, you can log in with the modified password.

The above method is applicable to the VPS of KVM architecture and the independent servers with IPMI management.