Resetting the root user password on a server
The root user password is generated when leasing a BareMetal server. You must save this password because you cannot view or restore it after the server starts.
If you have lost your BareMetal server root user password, you can create a new one. Depending on the situation, you can do it in different ways.
Tip
To paste text from the clipboard into the KVM console, right-click the Paste text here field in the upper-right corner of the KVM console and select Paste
from the context menu.
If you still can connect to the server as the root user using the SSH key specified when leasing the server, you can change the root user password without Rescue CD:
-
Connect to the server over SSH:
ssh root@<server_public_IP_address>
-
To change the root password of the BareMetal server OS, run this command:
passwd root
When prompted by the system, enter and confirm the new password:
New password: Retype new password:
Result:
passwd: password updated successfully
Note
At this stage, you can also add a new user SSH key for access to the server or change any other server OS settings that may prevent the server from booting or accepting connections correctly, as well as diagnose and troubleshoot errors as needed.
If you are unable to connect to the server using the SSH key specified when leasing the server, recover the root user password with the help of the Rescue CD boot image. Proceed in the KVM console.
To change the root user password or other BareMetal server settings:
-
Start the server from the Rescue CD image.
In the main SystemRescue menu, select Boot SystemRescue using default options, press ENTER and wait for SystemRescue to load.
-
View information about the server storage devices (disks and partitions created on them):
fdisk -l
Result:
Disk /dev/sda: 838.36 GiB, 900185481216 bytes, 1758174768 sectors Disk model: SAMSUNG MZ7GE900 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: D79F5407-DEEC-4A1D-983F-3AC5******** Device Start End Sectors Size Type /dev/sda1 2048 614399 612352 299M BIOS boot /dev/sda2 614400 21585919 20971520 10G Linux filesystem /dev/sda3 21585920 34168831 12582912 6G Linux filesystem /dev/sda4 34168832 1732861951 1698693120 810G Linux filesystem Disk /dev/sdb: 838.36 GiB, 900185481216 bytes, 1758174768 sectors Disk model: SAMSUNG MZ7GE900 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: CDZACB4C-1618-4BAF-A6BB-D2B9******** Device Start End Sectors Size Type /dev/sdb1 2048 614399 612352 299M BIOS boot /dev/sdb2 614400 21585919 20971520 10G Linux filesystem /dev/sdb3 21585920 34168831 12582912 6G Linux filesystem /dev/sdb4 34168832 1732861951 1698693120 810G Linux filesystem Disk /dev/md127: 6 GiB, 6438256640 bytes, 12574720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/md126: 9.99 GiB, 10729029632 bytes, 20955136 sectors = 512 bytes Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/md125: 809.88 GiB, 869596659712 bytes, 1698430976 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop: 824.97 MiB, 865046528 bytes, 1689544 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
In the example above, the
fdisk
utility outputs information about the physical disks (/dev/sda
and/dev/sdb
) and their partitions, as well as the partitions of the RAID array created on the server (/dev/md127
,/dev/md126
, and/dev/md125
).The disks
/dev/sda
and/dev/sdb
are used in the RAID array, whereas the root file system of the server OS resides in the809.88 GiB
/dev/md125
partition. This is the partition you need to mount. -
Mount the partition with the root file system of the BareMetal server OS:
mount /dev/md125 /mnt
-
Create a new SystemRescue OS shell with the environment in the previously mounted BareMetal server OS file system:
chroot /mnt /bin/bash
-
To change the root password of the BareMetal server OS, run this command:
passwd root
When prompted by the system, enter and confirm the new password:
New password: Retype new password:
Result:
passwd: password updated successfully
Note
At this stage, you can also add a new user SSH key for access to the server or change any other server OS settings that may prevent the server from booting or accepting connections correctly, as well as diagnose and troubleshoot errors as needed.
-
After performing all the required actions in the server’s file system, exit the environment you created.
exit
-
Unmount the BareMetal server file system:
umount /dev/md125 /mnt
Result:
umount: /mnt: not mounted.
-
Disable the virtual CD drive in the KVM console:
- In the KVM console window, in the top menu, select Media → Virtual Media Wizard... or click the CD icon.
- In the window that opens, click Disconnect under CD/DVD Media1.
- Click Close.
-
Restart the server:
reboot