All Products
Search
Document Center

Elastic Compute Service:Reset the logon password of an ECS instance

Last Updated:Dec 03, 2024

If you did not configure a logon password when you created an Elastic Compute Service (ECS) instance or you forget the logon password of an ECS instance, you can use the password reset feature. This topic describes how to reset the logon password of an ECS instance in the ECS console.

Comparison of the methods used to reset the logon password of an ECS instance

Method

Instance restart

Instance logon

Required instance status

Cloud Assistant Agent

Method 1: Reset the logon password of an ECS instance online in the ECS console

Not required.

Not required.

Running

Required.

  • Linux: Cloud Assistant Agent 2.2.3.398 or later.

  • Windows: Cloud Assistant Agent 2.1.3.398 or later.

For information about how to install Cloud Assistant Agent, see Install Cloud Assistant Agent.

Method 2: Reset the logon password of an ECS instance offline in the ECS console

Required.

Not required.

Running or Stopped

Not required.

Method 3: Reset the logon password of an ECS instance online by using Cloud Assistant

Not required.

Not required.

Running

Required.

Method 4: Reset the logon password of an ECS instance from within the instance

Not required.

Required.

Running

Not required.

Method 1: Reset the logon password of an ECS instance online in the ECS console

You can reset the logon password of an ECS instance online in the ECS console without the need to restart or log on to the instance. The new logon password takes effect within 1 minute. You can also use this method to change the logon password of a user that you created on the ECS instance. However, this method does not support batch operations and requires that Cloud Assistant Agent is installed on the ECS instance and the instance is in the Running state. For information about the requirements for the Cloud Assistant Agent version and the installation operations, see Comparison of the methods used to reset the logon password of an ECS instance.

Important

In this method, Cloud Assistant is used to encrypt and transfer the password text to prevent decryption and ensure password security.

  1. Log on to the ECS console and go to the Instance page.

  2. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  3. Find the ECS instance that you want to manage and choose image.png > Instance Attributes > Reset Instance Password in the Actions column.

  4. In the Reset Instance Password dialog box, select Online Reset, configure the parameters, and then click OK. The following table describes the parameters.

    image

    Parameter

    Description

    Logon Username

    When you reset the password online, you can enter the logon username that you specified when you created the ECS instance or the logon username of a custom user that you created on the instance. The system resets the password that corresponds to the specified logon username.

    New Password and Confirm Password

    The password must be 8 to 30 characters in length and contain at least three of the following character types:

    • Uppercase letters (A to Z)

    • Lowercase letters (a to z)

    • Digits (0 to 9)

    • Special characters: ( ) ` ~ ! @ # $ % ^ & * - _ + = | { } [ ] : ; ' < > , . ? /

    Note

    For Windows instances, logon passwords cannot start with a forward slash (/).

    Password Reset Method

    Select Online Reset.

    SSH Password Authentication

    This parameter is available only when you set the Password Reset Method parameter to Online Reset.

    • Enable: If you enable SSH Password Authentication, the system automatically sets the PasswordAuthentication parameter to yes in the /etc/ssh/sshd_config file. This allows you to use the specified password for authentication when you connect to the instance by using SSH.

      Note

      If your ECS instance originally uses password-based authentication, password-based authentication is automatically disabled after a key pair is bound to the instance. If you want to re-enable password-based authentication, you can use the Online Reset method to enable SSH Password Authentication and reset the logon password of the ECS instance. After you reset the logon password, you can use the new password to log on to the instance.

    • Retain Original Settings: If you select this option, you can change only the logon password of the instance. The value of the PasswordAuthentication parameter in the /etc/ssh/sshd_config file remains unchanged.

  5. (Optional) Use the new password to log on to the ECS instance.

    For more information, see Connect to an instance.

Method 2: Reset the logon password of an ECS instance offline in the ECS console

After you reset the logon password of an ECS instance offline in the ECS console, you must restart or start the ECS instance for the new logon password to take effect. You can batch reset the passwords of multiple ECS instances offline without the need to install Cloud Assistant Agent on the instances. Make sure that the ECS instances are in the Running or Stopped state. You can use this method to change only the password of the logon username that you specified when you created an ECS instance.

  1. Log on to the ECS console and go to the Instance page.

  2. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  3. Perform one of the following operations based on the number of instances whose logon passwords you want to reset at a time:

    • To reset the logon password of a single instance, find the instance and choose image.png > Instance Attributes > Reset Instance Password in the Actions column.

    • To reset the logon password of multiple instances at a time, select the instances and choose image.png > Reset Instance Password in the lower part of the Instance page.

  4. In the Reset Instance Password dialog box, select Offline Reset, configure the parameters, and then click OK. The following table describes the parameters.

    image

    Parameter

    Description

    Logon Username

    When you reset the password offline, the logon username that you specified when you created the ECS instance is used and cannot be changed. If you select the Offline Reset method, you can change the password only for the logon username that you specified when you created an ECS instance.

    New Password and Confirm Password

    The password must be 8 to 30 characters in length and contain at least three of the following character types:

    • Uppercase letters (A to Z)

    • Lowercase letters (a to z)

    • Digits (0 to 9)

    • Special characters: ( ) ` ~ ! @ # $ % ^ & * - _ + = | { } [ ] : ; ' < > , . ? /

    Note

    For Windows instances, logon passwords cannot start with a forward slash (/).

    Password Reset Method

    Select Offline Reset.

    • If the instance is in the Running state, click Restart Now.

      Warning

      The restart operation stops the instance for a short period of time and may interrupt services that are running on the instance. We recommend that you restart the instance during off-peak hours.

    • If the instance is in the Stopped state, the new password takes effect when you start the instance.

  5. (Optional) Use the new password to log on to the ECS instance.

    For more information, see Connect to an instance.

Method 3: Reset the logon password of an ECS instance online by using Cloud Assistant

When you use Cloud Assistant to reset the password of an ECS instance, you do not need to log on to the instance or restart the instance. You can configure a schedule to run or immediately run a Cloud Assistant command to reset the password of the instance.

  1. Log on to the ECS console and go to the Instance page.

  2. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  3. Click the ID of the instance for which you want to run the Cloud Assistant command to go to the Instance Details page.

  4. Click the Remote Commands/Files tab, and then click Send Remote Commands.

  5. Configure the parameters to reset the logon password. The following table describes the parameters.

    Use the default settings for other parameters.

    Parameter

    Description

    Execution Plan

    Select Immediate execution.

    Command Type

    Select a command type.

    • For Linux ECS instances, select Shell.

    • For Windows ECS instances, select Bat or PowerShell.

    Command Content

    The content of the command. In the Command Content field, enter one of the following commands based on the operating system of your instance to change the logon password:

    • Linux ECS instance:

      echo "root:<yourPassword>"|chpasswd
    • Windows ECS instance:

      net user "Administrator" "<yourPassword>"
    Note
    • Replace <yourPassword> with a new password.

    • The password must be 8 to 30 characters in length. The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. The password of a Windows ECS instance cannot start with a forward slash (/).

  6. Click Run.

Method 4: Reset the logon password of an ECS instance from within the instance

When you perform operations in the operating system of an ECS instance, you can reset the logon password of the instance based on your business requirements without the need to log on to the ECS console. After you reset the password, the new password immediately takes effect without the need to restart the instance.

Reset the logon password of a Linux ECS instance

In this example, an ECS instance that runs Alibaba Cloud Linux 3.2104 LTS 64-bit is used. To reset the logon password of the Linux ECS instance, perform the following steps:

  1. Connect to the Linux ECS instance.

    For more information, see Connect to a Linux instance by using a password or a key.

  2. Run the following command to reset the logon password:

    sudo passwd <Username>
  3. Enter a new password and press the Enter key.

  4. Re-enter the new password and press the Enter key.

    The following command output indicates that the logon password of the Linux ECS instance is reset.

    实例登录.png

    Note

    If you log on to an ECS instance by using a key pair to reset the logon password of the instance, take note of the following items:

    After you bind the key pair to the ECS instance, password-based authentication is automatically disabled. You cannot log on to the ECS instance by using the logon password. To re-enable password-based authentication, set the PasswordAuthentication parameter in the /etc/ssh/sshd_config file to yes and restart the sshd service for the configuration to take effect. Then, you can log on to the ECS instance by using the logon password. For more information, see What do I do if I cannot connect to a Linux ECS instance by using a password?

Reset the logon password of a Windows ECS instance

In this example, an ECS instance that runs Windows Server 2019 is used. To reset the logon password of the Windows ECS instance, perform the following steps:

  1. Connect to the Windows ECS instance.

    For more information, see Connect to a Windows instance by using a password or key.

  2. On the Windows desktop, right-click the image.png icon and then select Run. In the Run window, enter compmgmt.msc and press the Enter key.

  3. In the Computer Management window, choose Computer Management > Local Users and Groups > Users.

  4. Right-click a username, such as Administrator, and select Set Password.

  5. In the Set Password for Administrator window, click Proceed. Enter a new password in the New Password field. Then, re-enter the new password in the Confirm Password field.

  6. Click OK.

    If the following window appears, the logon password of the Windows ECS instance is reset.

    image.png