It may happen that on occasion, we forget the root password and cannot log in. This generally has a very simple solution, as from the Clouding Customer Area, it is possible to reset the password with just one click.
This option is located within the settings of each server in our account. If we click on one of our servers and go to the “Access” tab, we will find the “Reset Password” option, which will allow us to reset the password to a new one that we will receive via email.
Nevertheless, there are occasions when this process can fail for various reasons, and we cannot reset the password this way.
For that, there is a very simple way to reset the password through the VNC console provided in the Customer Area.
The process involves entering a maintenance mode of the kernel where we will have access to the root account without needing to enter the password.
This is not an exploitation method of any vulnerability nor any hacking technique. We simply use GRUB parameters to gain root access to a specific system for maintenance tasks.
To perform the process, we need to go to our Clouding account and select the server we want to reset the password for using GRUB.
Click on the “VNC Console” tab, and a small console window will open where you should see something similar to this:
Next, click on the button in the upper right corner of the image that says “Send CtrlAltDel”. This button sends a signal to the machine to restart. While it is restarting, we will stop the machine when the GRUB loads.
Press the button, and then press the ESC button repeatedly until you see the following screen (in Debian/Ubuntu or CentOS, it may look slightly different, especially in terms of colors):
At this point, press the "e" key to edit the Linux kernel boot parameters.
Move the cursor of the editor to the line that says:
linux /boot/vmlinuz-3.14.43-1 root=UUID=7b649fa5-37b8-480e-a040-5b6cbc530670 ro console=tty1 console=ttyS0,115200n8 nomodeset onsoleblanck=0
Remove the console=ttyS0,115200n8 parameter and add rw init=/bin/bash.
The editor defaults to the English keyboard, so to type the "=" character, you will need to press the "+" key (next to Enter) on the Spanish keyboard.
Once you have entered the new parameter, press F10 to start that kernel with this configuration. After a moment, you will see the following:
If you press Enter, you will see the prompt appear:
With the prompt on your screen, simply change the root password using the following command and enter the new password (be careful with special characters, as the English keyboard is used at this point):
With the root password changed, click on the “Send CtrlAltDel” button to restart your server.
In the console, you will see that we return to the initial image, but this time, we will log in with root to verify that the password has been successfully changed.
After logging in and confirming that everything has gone well, close it with the exit command.
With this simple step, we have changed the root password, and we can once again access via SSH and continue managing/maintaining our server.