How to reset the root password on Centos 7

Follow

Sometimes we forget things. If you forget the root password to your CentOS 7 machine, it’s virtually impossible to reset it while you’re locked out.
This brief tutorial is going to show you a simple trick that you can use to reset your forgotten root password for CentOS 7 servers.

Note: Before you can change the password, you'll need access to the console of the server. You can get the console details by logging into the customer portal at mysau.com.au


1. Open the console to the server.

The console is one of the tabs you have when you are viewing the product information. 
When in console, you can try logging into the server in case it was blocking your login due to the IP address. If you still can't log in, then you'll need to progress to step 2.


2. Reboot the server

For Dedicated servers, you will have buttons like these:

For Virtual servers, they will look like this:

Just click the reboot button and it'll start the process.

Now watch the console. You'll see the server go offline, then you'll see the process where it's coming back online. When you see the boot menu like below:

Quickly press the up and down arrows on the keyboard to stop the timer from running out or press "e" on the keyboard to jump straight to editing the boot directives.

Now use the arrow keys to navigate to the kernel arguments line and where it has "ro"

change it to "rw init=/sysroot/bin/sh"

Then press Control x to start Centos 7.

It will boot straight to a command line. From there, you need to run: 
chroot /sysroot
then 
passwd

It will prompt you for a new password. Once you've set it, just reboot the server again. When the server comes back online, it'll have the new password for the root account.

Have more questions? Submit a request

Comments

Powered by Zendesk