How to restore your root password after forgetting or being exploited via Single user mode


I have been seeing a few people unsure what to do when they lose or forget their root password. Some are resorting to reinstalling their server thinking this is the only option, however there is another option with Rimuhosting.

First you need to go into your Rimuhosting Control panel, find your server in the Server List. You will now see in the options available , and the one you want is ‘Get Console Access’

getconsoleaccessThis will load a page that allows you to set a console password, or add your SSH key. Either option works, which ever you prefer. At the top of this page you will see what you need to SSH to (circled in red)

add-ssh-key

Once you have set the password, or added your SSH key, you can connect to that SSH, and that will access your VPS via the host server itself. This allows you to boot the server into single user mode, or fix things that break.

Now you have access to the console, you need to reboot the server into single user mode. You can do this via the control panel page again under the reboot option.

restboot2Once you have rebooted to single user mode, connect to the console by ssh’ing to the host server a few steps prior (ususally servername@hostip ). This will look like this

consoleitselfSo now you have a full root console to do as you like, you just need to mount that read/write and change the password. This is how i did that in this case.

passwdchangeThe main part to note was that i mounted the drive read.write using the command

mount -oremount,rw /

Then i changed the password using passwd. You can check any other things on the server at the same time, particularly if its been hacked. Just be aware you have no networking at this time.
The final commands were to remount the hdd read-only again and sync, neither of which is strictly necessary, it just makes sure the hdd has finished being written too before rebooting.

So once the password is reset, finally you can then just reboot the server normally, not into single usermode, and connect with SSH and the new password.

If for any reason you have a problem with any of this, just let us know, we can do that for you.

,