How do I reset my root user password on my virtual Linux server?


One of the advantages of a VPS or hybrid server is that they are virtualised, providing additional access to manage the server even if you are locked out of the root account.

You can use the out-of-band SSH console to get back into your server if you have forgotten the root password.

Getting an SSH Client

You will need an SSH client to access the out-of-band console.

If your computer is running OS X or Linux, you have the Terminal application already installed on your computer.

If your computer is running Windows, you will need to download a third-party SSH client, such as PuTTY.

Prepare Your Server

You will first need to turn your server off.

To do this:

  1. Log into your Customer Area
  2. Click ‘Manage VPS and Hybrid Servers’
  3. Click the icon next to the server you want to change the password for
  4. Click ‘Turn Off Server’

Screenshot of the Heart Internet Server Control Panel

Log into Your Console

When you have turned off your server, you can now log in via the SSH console.

To get the login details:

  1. Click on the ‘Console’ tab in your server’s Control Panel
  2. Take the details from the ‘Text-based (SSH) console’ section
  3. Connect to your SSH console by entering username@ssh-host
  4. Add in the password (revealed in the Control Panel)

 Boot the Server

Once you have logged into the console, you should see the following screen:

Screenshot of an SSH window showing you that your server is powered off

To boot the server:

  1. Enter ‘P’
  2. Wait for the server to boot

Screenshot showing the operating system choices on your server

This screen shows the operating system choices.  The top one is the default – the one that would normally start – but you want to start the server in single-user mode.

Single-user mode does not prompt you for a root login and allows you to change the password without prompting you for it.

To edit the boot parameters, allowing you to start the server in single-user mode:

  1. Press E
  2. Use the arrow keys to highlight the Kernel Boot Parameters

Screenshot showing the kernel boot parameters for your operating system

  1. Press E again

Screenshot of the BASH-Like line editing

  1. Press space, then 1

Screenshot of the BASH-like Line editing

  1. Press Enter
  2. Press B to boot the server
  3. The server will start booting in single-user mode

 Resetting the Password

Once the server has booted up, you will see this:

Screenshot of your server in single-user mode

Dependent on the Linux distribution, your file system may be read-only when loaded in single-user mode.

To check:

  1. Enter

mount

  1. Make certain that the / file system has (rw) or (ro) after it
  2. If the file system is read-only, it will say (ro), and you will need to switch it to writable

To switch the file system to writable:

  1. Enter

mount -o remount,rw /

To reset the root password:

  1. Enter

passwd

  1. Enter in your new password and press enter

Screenshot of where to enter your new password

  1. Enter in the password again and press enter
  2. Your new password will be saved

Reboot the Server

Once the password has been changed, you can reboot the server.

To reboot the server:

  1. Enter

reboot

  1. The server will reboot in normal mode


Article ID: 471
Created On: Mon, Mar 16, 2015 at 5:14 PM
Last Updated On: Thu, Apr 23, 2015 at 12:03 PM

Online URL: https://www.heartinternet.uk/support/article/how-do-i-reset-my-root-user-password-on-my-virtual-linux-server.html