Linux

How To Reset a CentOS 7 Root Password

Just like with other distributions, you can use the NoVNC console to reset CentOS 7 root password. By adding a simple line of code to the boot configuration you can update the password and get access back to your instance. To get started and reset a lost CentOS 7 password, log in to your client account. Access the Discovery control panel for the instance you want to change the password on.

Access NoVNC Console

So, from the control panel click the NoVNC icon to bring up the console. Select the gear icon to the left and reboot the instance. When you see the list of Kernels, press the up arrow key to stop the NVMe VPS from automatic boot.

Select Kernel

Next, select the kernel you usually use and press the “e” key.

reset centos 7 root password

Find the line starting  linux16 and the section starting “to”

reset lost centos 7 root password

So next, change “ro” to “rw” and add “init=/sysroot/bin/sh“. So the line looks like the below code. Once done press CNTRL + X to start the instance in single-user mode.

rw init=sysroot/bin/sh

Reset CentOS 7 Password

In single-user mode enter the below commands to update the root password. On reboot, the instance password will be updated.

chroot /sysroot
passwd root
touch /.autorelabel
exit
reboot

Instead of using passwords why not use an SSH key? By using an SSH key you can log in to your instances without having to type a password and, adding an SSH key is easy. Go passwordless. Learn how to Create SSH Keys and install them in the Discovery control panel.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button