Resetting the Password for Logging In to a Linux ECS
Scenarios
If the password reset plug-in is not installed on a Linux ECS or a password reset does not take effect, you can reset the password following the instructions provided in this section.
For details about the operations performed on Windows ECSs, see Resetting the Password for Logging In to a Windows ECS.
- If your ECS has password reset plug-in installed, follow the instructions provided in Resetting the Password for Logging In to an ECS on the Management Console to obtain a new password.
- If your ECS was created using a public image, the password reset plug-in was installed on the ECS by default. To reset the password, see Resetting the Password for Logging In to an ECS on the Management Console.
- Before you perform operations in this section, we recommend you to back up the system disk to prevent data loss.
Prerequisites
- A temporary Linux ECS which locates in the same AZ as the target ECS is available.
- You have bound an EIP to the temporary ECS.
Procedure
- Download the script for resetting the password and upload the script to the temporary ECS.
Contact the administrator to obtain the password reset script. Use a connection tool, such as WinSCP, to upload the obtained changepasswd.sh script to the temporary ECS.
To download WinSCP, log in at https://winscp.net/.
- Stop the original Linux ECS, detach the system disk from it, and attach the system disk to the temporary ECS.
- Log in to the management console.
- Under Computing, click Elastic Cloud Server.
- Stop the original ECS, switch to the page providing details about the ECS, and click the Disks tab.
Do not forcibly stop the original ECS. Otherwise, password reset may fail.
- Locate the row containing the system disk to be detached and click Detach to detach the system disk from the ECS.
- Attach the system disk to the temporary ECS.
- On the page providing details about the temporary ECS, click the Disks tab.
- Click Attach Disk. In the displayed dialog box, select the system disk detached in step 2.d and attach it to the temporary ECS.
- Log in to the temporary ECS remotely and reset the password.
- Locate the row containing the temporary ECS and click Remote Login in the Operation column.
- Run the following command to view the directory of the system disk detached from the original Linux ECS now attached to the temporary ECS:
fdisk -l
Figure 1 Viewing the directory of the system disk
- Run the following commands in the directory where the changepasswd.sh script is stored to run the script for resetting the password:
chmod +x changepasswd.sh
./changepasswd.sh
When you run the password reset script, if the system displays a message indicating that there is no command related to logical volume manager (LVM), such as the message "no lvs command", install an LVM tool on the temporary ECS. The LVM2 tool is recommended, which can be installed by running the yum install lvm2 command.
If the original ECS and the temporary ECS both run CentOS 7, a mount failure may occur during script execution. To resolve this issue, replace mount $dev $mountPath with mount -o nouuid $dev $mountPath in the script.
- Enter the new password and the directory obtained in step 4.b as prompted.
If the following information is displayed, the password has been changed:
set password success.
- (Optional) Enable remote root login for non-root users.
Modify the following settings:
- Change PasswordAuthentication no to PasswordAuthentication yes.
Alternatively, uncomment PasswordAuthentication yes.
- Change PermitRootLogin no to PermitRootLogin yes.
Alternatively, uncomment PermitRootLogin yes.
- Change the value of AllowUsers to root.
Search for AllowUsers in the file. If AllowUsers is missing, add AllowUsers root at the end of the file.
- Change PasswordAuthentication no to PasswordAuthentication yes.
- Stop the temporary ECS, detach the system disk, attach the system disk to the original Linux ECS, and restart the original Linux ECS.
- Stop the temporary ECS, switch to the page providing details about the ECS, and click the Disks tab.
- Click Detach to detach the data disk attached in step 2.
- On the page providing details about the original Linux ECS, click the Disks tab.
- Click Attach Disk. In the displayed dialog box, select the data disk detached in 6.b.
- Restart the original Linux ECS.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot