All Products
Search
Document Center

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

Last Updated:Sep 14, 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.

Methods

Methods for resetting 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 in the ECS console

Online Reset

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.

Offline Reset

Required.

Not required.

Running or Stopped

Not required.

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

Not required.

Not required.

Running

Required.

Method 3: 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 in the ECS console

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

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

  4. 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 one 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.

  5. In the Reset Instance Password dialog box, configure the parameters and click OK.

    image

    Parameter

    Description

    Logon Username

    • If you select the Online Reset method, you can specify a logon username and password or change the logon username and password that you specified when you created an ECS instance.

    • If you select the Offline Reset method, you can change the password that you specified when you created an ECS instance, but you cannot change the logon username.

    New Password and Confirm Password

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

    • 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

    • Online Reset: After you reset the password of an ECS instance online, you do not need to restart the instance. The new password is expected to take effect within 1 minute. You cannot reset the passwords of multiple instances online.

      Important

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

    • Offline Reset: After you reset the password offline, you must restart or start the instance for the new password to take effect.

      • 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.

    SSH Password Authentication

    This parameter is available only when Password Reset Method is set 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 connect to the instance by using SSH and log on with the specified password.

    • Retain Original Settings: If you select this option, you can change only the logon password of the instance.

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

    For more information, see Connect to an instance.

    Note

    Although a key pair is bound to the instance, you can use the new password to log on to the instance after you reset the password.

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

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

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

  4. Click the ID of the instance whose logon password you want to reset to go to the Instance Details page.

  5. Click the Remote Commands/Files tab and click Send Remote Commands.

  6. 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 server cannot start with a forward slash (/).

  7. Click Run.

Method 3: 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

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.

    The following window indicates that the logon password of the Windows ECS instance is reset.

    image.png