Help Center> Elastic Cloud Server> Troubleshooting> Passwords and Key Pairs> Troubleshooting Password Reset for User root in the Single-User Mode on a Linux ECS

Troubleshooting Password Reset for User root in the Single-User Mode on a Linux ECS

Scenarios

  • The one-click password reset function on the management console does not take effect.
  • The password reset plug-in is not installed and the password of user root is lost.

Constraints

Resetting the password of user root requires to restart the ECS and switch to the single-user mode. Therefore, identify the risks and back up your data.

CentOS 7 or EulerOS Series

  1. On the ECS management console, restart the ECS and click Remote Login.
  2. Press the up arrow key to prevent automatic system startup. When the kernels are displayed, press e to enter the editing mode.
    Figure 1 Entering the kernel editing mode

    The Euler image encrypts the GRUB file by default. When you edit the kernel parameters, you need to contact customer service to obtain username and password.

  3. Locate the row containing linux16 and perform the following operations:
    1. Delete the parameters not needed.

      Retain console=tty0 console=ttyS0 for BMS.

    2. Change ro to rw for mounting the root partition with read-write permissions.
    3. Add rd.break and press Ctrl+X.
      Figure 2 Before the modification
      Figure 3 After the modification
  4. Run the following command to go to the /sysroot directory:

    # chroot /sysroot

  5. Reset the password of user root:

    # passwd root

  6. (Optional) Run the following command to enable SELinux if required:

    # touch /.autorelabel

  7. Exit the current root directory:

    # exit

  8. Restart the ECS.

    # reboot

CentOS 6 or Red Hat 6 Series

  1. On the ECS management console, restart the ECS and click Remote Login.
    When booting the system, press Esc to stop the countdown and enter a GRUB menu.
    Figure 4 GRUB menu
  2. Move the cursor to the first default kernel and press e to edit the commands before booting.
    Figure 5 Pressing e to edit commands
  3. Move the cursor to the row containing kernel and press e.
    Figure 6 Selecting the row that contains kernel
  4. Move the cursor to the row that contains quiet, enter a space and 1 after quiet, and press Enter.
    Figure 7 Editing in the row that contains quiet
  5. Press b to boot the kernel and change to runlevel 1 (single-user mode).
  6. When the prompt # is displayed, run the following command to reset the password:

    # passwd root

  7. Restart the ECS.

    # reboot

Debian or Ubuntu Series

  1. On the ECS management console, restart the ECS and click Remote Login. Press Esc to stop the countdown and enter a GRUB menu.
    Figure 8 GRUB menu
  2. Press e to enter the GRUB2 editing mode.
  3. Locate the row that contains linux, delete the parameters not needed, and change ro to rw (mount the root partition in read-write mode), and add init=/bin/bash to the end of the row.
    Figure 9 Modifying ro parameter
  4. Press Ctrl+X to enter the rescue mode.
  5. Reset the password of user root:

    # passwd root

  6. Restart the ECS.

    # reboot

SUSE 11 Series

  1. On the ECS management console, restart the ECS and click Remote Login. Press the up arrow key to stop the countdown and enter a GRUB menu.
  2. Delete the parameter of Boot Options and add init=/bin/bash.
    Figure 10 Boot options
  3. Press Enter to switch to the single-user mode.
  4. Reset the password of user root:

    # passwd root

  5. Restart the ECS.

    # reboot

SUSE 12 Series

  1. On the ECS management console, restart the ECS and click Remote Login. Press Esc to stop the countdown and enter a GRUB menu.
    Figure 11 GRUB menu
  2. Press e to enter the GRUB2 editing mode.
  3. Move the cursor to the end of the row containing linux and add init=/bin/bash to the end of the row.
    Figure 12 Adding init=/bin/bash
  4. Press Ctrl+X to enter the rescue mode.
  5. Reset the password of user root:

    # passwd root

  6. Restart the ECS.

    # reboot