Updated on 2025-09-15 GMT+08:00

Resetting the Password in the ECS OS

Scenarios

This section describes how to reset the password for logging in to an ECS in the OS when the password is about to expire, the password is forgotten, or you are logging in to the ECS for the first time. It is a good practice to change the initial password upon the first login.

  • Windows ECS: Log in to the ECS and reset the password.
  • Linux ECS: Enter the Debug Shell or single-user mode, or use a key pair to reset the password.

You are advised to reset the ECS login password on the management console by referring to Resetting the Password for Logging In to an ECS on the Management Console.

Prerequisites

The ECS can be logged in.

Background

Table 1 shows the ECS password complexity requirements.

Table 1 Password complexity requirements

Password complexity requirements

ECS Creation

Password Reset

Length

Must contain 8 to 26 characters.

Must contain 8 to 26 characters.

Characters

Must contain at least three of the supported four character types.

Must contain at least three of the supported four character types.

Security

  • Cannot contain the username or the username spelled backwards.
  • Cannot contain more than two consecutive characters in the same sequence as they appear in the username. (This requirement applies only to Windows ECSs.)
  • Cannot contain the username or the username spelled backwards.
  • Cannot contain more than two consecutive characters in the same sequence as they appear in the username. (This requirement applies only to Windows ECSs.)

Other

None

Cannot start with a slash (/) for Windows ECSs.

Supported Characters

Uppercase letters

Uppercase letters

Lowercase letters

Lowercase letters

Digits

Digits

  • Special characters for Linux ECSs: !@$%^-_=+[{}]:,./?~#*
  • Special characters for Windows ECSs: !@$%^-_=+[{()}]:,./?~#*
  • Online password reset:

    @%-_=+[]:./^,{}? (only applied to Linux)

    $@%-_=+[]:./,? (only applied to Windows)

  • Offline password reset:

    Special characters for Linux ECSs: !@%-_=+[]:./?

    Special characters for Windows ECSs: !@%-_=+[]:./?

Windows ECS

For a Windows ECS, log in to the ECS using the old password and reset the password in the OS.

  1. Log in to the Windows ECS.

    For details, see Logging In to a Windows ECS.

  2. Press Win+R to start the Run dialog box.
  3. Enter cmd to open the command-line interface (CLI) window.
  4. Enter a new password that meets the requirements listed in Table 1.

    net user Administrator new-password

Linux ECS

For a Linux ECS, you can reset the password in any of the following ways:

  1. Enter the Debug Shell mode of the Linux ECS.
  2. Run the following command to change the password:

    passwd root

    Enter a new password. If the message "all authentication tokens updated successfully" is displayed, the password is set successfully.

  3. Run the following command to restart the ECS:

    reboot -f

    Figure 1 Output
  1. Enter the single-user mode of the Linux ECS.
  2. Run the following command to change the password:

    passwd root

    Enter a new password. If the message "all authentication tokens updated successfully" is displayed, the password is set successfully.

  3. Run the following command to restart the ECS:

    reboot -f

    Figure 2 Output (CentOS 7/8, CentOS Stream 8/9, Rocky Linux 8/9, or AlmaLinux 8/9)
    Figure 3 Output (Ubuntu 20–24, Debian 10–12, openSUSE, or openEuler)
  1. Use the existing key file to log in to the ECS as user root through SSH.

    For details, see Login Using an SSH Key.

  2. Run the following command to reset the password of user root:

    passwd

    To reset the password of another user, replace passwd with passwd username.

  3. Enter a new password that meets the requirements listed in Table 1 as prompted.
    New password:
    Retype new password:
    If the following information is displayed, the password has been changed:
    passwd: all authentication tokens updates successfully