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.
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.
In this method, Cloud Assistant is used to encrypt and transfer the password text to prevent decryption and ensure password security.
Log on to the ECS console and go to the Instance page.
In the top navigation bar, select the region and resource group to which the resource belongs.
Find the ECS instance that you want to manage and choose
in the Actions column.In the Reset Instance Password dialog box, select Online Reset, configure the parameters, and then click OK. The following table describes the parameters.
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:
( ) ` ~ ! @ # $ % ^ & * - _ + = | { } [ ] : ; ' < > , . ? /
NoteFor 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 toyes
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.NoteIf 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.
(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.
Log on to the ECS console and go to the Instance page.
In the top navigation bar, select the region and resource group to which the resource belongs.
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
in the Actions column.To reset the logon password of multiple instances at a time, select the instances and choose
in the lower part of the Instance page.
In the Reset Instance Password dialog box, select Offline Reset, configure the parameters, and then click OK. The following table describes the parameters.
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:
( ) ` ~ ! @ # $ % ^ & * - _ + = | { } [ ] : ; ' < > , . ? /
NoteFor 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.
WarningThe 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.
(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.
Log on to the ECS console and go to the Instance page.
In the top navigation bar, select the region and resource group to which the resource belongs.
Click the ID of the instance for which you want to run the Cloud Assistant command to go to the Instance Details page.
Click the Remote Commands/Files tab, and then click Send Remote Commands.
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>"
NoteReplace <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 (/).
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:
Connect to the Linux ECS instance.
For more information, see Connect to a Linux instance by using a password or a key.
Run the following command to reset the logon password:
sudo passwd <Username>
Enter a new password and press the
Enter
key.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.
NoteIf 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 toyes
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:
Connect to the Windows ECS instance.
For more information, see Connect to a Windows instance by using a password or key.
On the Windows desktop, right-click the icon and then select Run. In the Run window, enter
compmgmt.msc
and press theEnter
key.In the Computer Management window, choose
.Right-click a username, such as Administrator, and select Set Password.
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.
Click OK.
If the following window appears, the logon password of the Windows ECS instance is reset.