此内容的本地化语言页面暂未提供。我们将不断努力以提供本地化语言版本。感谢您的关注。

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page
Help Center/ Elastic Cloud Server/ User Guide (Paris Regions)/ Passwords and Key Pairs/ Password Reset/ Resetting the Password for Logging In to a Linux ECS

Resetting the Password for Logging In to a Linux ECS

Updated on 2025-01-27 GMT+08:00

Scenarios

Keep your password secure. Reset the password if:

  • The password is forgotten.
  • The password has expired.

This section describes how to reset the password of user root. After resetting the password, you can log in to the ECS, and change the private key or reset the password of a non-root user.

Prerequisites

  • A temporary Linux ECS is available. It is located in the same AZ and has the same CPU architecture as the target ECS.
  • You have bound an EIP to the temporary ECS.

Procedure

  1. Download the script for resetting the password and upload the script to the temporary ECS.

    Download and decompress 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/.

  2. Download the script for resetting the password and upload the script to the temporary ECS.

    Contact customer service 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/.

  3. Stop the original Linux ECS, detach the system disk from it, and attach the system disk to the temporary ECS.
    1. Log in to the management console.
    2. Under Computing, click Elastic Cloud Server.
    3. Stop the original ECS, switch to the page providing details about the ECS, and click the Disks tab.
      NOTE:

      Do not forcibly stop the original ECS. Otherwise, password reset may fail.

    4. Locate the row containing the system disk to be detached and click Detach to detach the system disk from the ECS.
  4. Attach the system disk to the temporary ECS.
    1. On the page providing details about the temporary ECS, click the Disks tab.
    2. Click Attach Disk. In the displayed dialog box, select the system disk detached in step 3.d and attach it to the temporary ECS.
  5. Log in to the temporary ECS remotely and reset the password.
    1. Locate the row containing the temporary ECS and click Remote Login in the Operation column.
    2. 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
    3. 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.

      NOTE:

      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.

    4. Enter the new password and the directory obtained in step 5.b as prompted.
      If the following information is displayed, the password has been changed:
      set password success.
  6. (Optional) Enable remote root login for non-root users.

    vi /etc/ssh/sshd_config

    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.

  7. Stop the temporary ECS, detach the system disk, attach the system disk to the original Linux ECS, and restart the original Linux ECS.
    1. Stop the temporary ECS, switch to the page providing details about the ECS, and click the Disks tab.
    2. Click Detach to detach the data disk temporarily attached in step 4.
    3. On the page providing details about the original Linux ECS, click the Disks tab.
    4. Click Attach Disk. In the displayed dialog box, select the data disk detached in 7.b.
  8. Restart the original Linux ECS.

我们使用cookie来确保您的高速浏览体验。继续浏览本站,即表示您同意我们使用cookie。 详情

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback