Losing a password can be stressful especially when you have important VMs and data stored on your machine. In this article, we will show you how to use OVHcloud's Rescue Mode kernel and IPMI to recover the root password in Proxmox VE 6.
Prerequisites
- Familiarity with Terminal
- Ability to Access IPMI
Topics
Editing the Shadow File in Rescue Mode
The first step to recovering our password is to access our server via rescue mode and delete our password data in our server's filesystem. To begin, first log into the OVHcloud Control Panel. Click Bare Metal Cloud at the top of the page and choose the relevant server from the left-hand column. In the "General information" box, click the ... next to "Boot" and select Edit from the drop-down menu.
On the following pop-up menu, choose Boot in rescue mode and select the "rescue64-pro" kernel from the drop-down menu. Click Next when you have confirmed the settings are correct.
Next, in the "Service status" box, click the ... next to "Status" and select Restart from the drop-down menu.
Allow the server a few minutes to finish rebooting. Once the reboot is completed, you will receive an email with the credentials to access your Rescue Mode.
Note: If you have not received an email within a few minutes, check your email inbox's Spam folder.
You can SSH into Rescue Mode as normal providing the password contained in the email when prompted.
$ ssh root@SERVER_IP
Once you are inside the Rescue Mode environment, find your root partition using the following command.
# lsblk
Sample Output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 3.7T 0 disk ├─sdb4 8:20 0 3.6T 0 part │ └─md127 9:127 0 3.6T 0 raid1 │ └─vg-data 251:0 0 3.6T 0 lvm ├─sdb2 8:18 0 20G 0 part │ └─md126 9:126 0 20G 0 raid1 ├─sdb3 8:19 0 1G 0 part └─sdb1 8:17 0 511M 0 part sdc 8:32 0 3.7T 0 disk ├─sdc2 8:34 0 20G 0 part │ └─md126 9:126 0 20G 0 raid1 ├─sdc3 8:35 0 1G 0 part ├─sdc1 8:33 0 511M 0 part └─sdc4 8:36 0 3.6T 0 part └─md127 9:127 0 3.6T 0 raid1 └─vg-data 251:0 0 3.6T 0 lvm sda 8:0 0 3.7T 0 disk ├─sda4 8:4 0 3.6T 0 part │ └─md127 9:127 0 3.6T 0 raid1 │ └─vg-data 251:0 0 3.6T 0 lvm ├─sda2 8:2 0 20G 0 part │ └─md126 9:126 0 20G 0 raid1 ├─sda5 8:5 0 2M 0 part ├─sda3 8:3 0 1G 0 part └─sda1 8:1 0 511M 0 part
If you used a standard installation, the root partition in this instance will be the RAID partition md126
. If you configured your own partitions, find the name corresponding to your root partition. Mount this partition using the following command, replacing md126
with the name from your lsblk
output.
# mount /dev/md126 /mnt
Next, open the shadow file with a text editor using the following command:
# vim /mnt/etc/shadow
Find the line labeled "root" and delete all content between the first and second colon in the line. The line should look something like this when you are finished.
root::19012:0:99999:7:::
Save and close the file. Exit Rescue Mode. Then, from the OVHcloud Control Panel, change the netboot on the server back to Boot from the hard disk. Reboot your server again and wait a few minutes for the reboot to complete. Next, we will access the server via IPMI and set a new root password.
Warning: You will not be able to log into the server via SSH or via the Proxmox user interface until you complete the next step.
Setting a New Root Password in IPMI
To access IPMI from the OVHcloud Control Panel, navigate back to your server's landing page as described above. Click the IPMI tab.
Note: If your server allows you to use the web browser (HTML5) version of IPMI, always choose this one. If Java is your only option, ensure you are using the IPMI from a Windows or Linux OS as Java does not work well on macOS.
Open the KVM when you are prompted to do so. If the server is still booting up, wait for it to finish.
If the login prompt does not pop up once the reboot is complete, just press ENTER
on your keyboard. At the prompt, login as root. It will not ask you for a password. Set a new password using the following command.
# passwd
Type your new password twice to confirm the change. Close the IPMI window and you are done.
Conclusion
Having read this article, you should now be able to recover a lost root password for your Proxmox VE 6 environment.