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

Using an SSH Key Pair

Updated on 2022-02-22 GMT+08:00

Scenarios

To ensure system security, you are advised to use the key authentication mode to authorize the user who attempts to log in to a BMS. Therefore, you must use an existing key pair or create a new one for remote login authentication.

  • Creating a Key Pair

    If no key pair is available, create one that contains a public and a private key used for login authentication. You can use either of the following methods:

  • Using an existing key pair

    If a key pair is available locally, for example, generated using PuTTYgen, you can import the public key on the management console so that the system maintains the public key file. For details, see Import a Key Pair.

Create a Key Pair on the Management Console

  1. Log in to the management console.
  2. Under Computing, click Bare Metal Server.

    The BMS console is displayed.

  3. In the navigation tree, choose Key Pair.
  4. On the right side of the page, click Create Key Pair.
  5. Enter the key name and click OK.

    An automatically populated key name consists of KeyPair- and a 4-digit random number. Change it to an easy-to-remember one, for example, KeyPair-xxxx_bms.

  6. Download the private key file. The file name is the specified key pair name with a suffix of .pem. Store the private key file securely. In the displayed dialog box, click OK.
    CAUTION:

    You can save the private key file only once. When you create a BMS, provide the key pair name. Each time you log in to the BMS using SSH, you need to provide the private key.

Create a Key Pair Using PuTTYgen

  1. Obtain the public and private keys.

    1. Double-click puttygen.exe. The PuTTY Key Generator window is displayed.
      Figure 1 PuTTY Key Generator
    2. Click Generate.

      The key generator automatically generates a key pair that consists of a public key and a private key. The public key is that shown in the red box in Figure 2.

      Figure 2 Obtaining the public and private keys

  2. Copy the public key content to a .txt file and save the file in a local directory.

    NOTE:

    Do not save the public key by clicking Save public key. Storing a public key by clicking Save public key of PuTTYgen will change the format of the public key content. Such a key cannot be imported to the management console.

  3. Save the private key file.

    The format in which to save your private key varies depending on application scenarios: To ensure BMS security, you are limited to downloading the private key only once.

    • Saving the private key in .ppk format

      When you are required to log in to a Linux BMS using PuTTY, you must use the .ppk private key. To save the private key in .ppk format, perform the following operations:

      1. On the PuTTY Key Generator page, choose File > Save private key.
      2. Save the private key, for example, kp-123.ppk, to the local PC.
    • Saving the private key in .pem format

      When you are required to log in to a Linux BMS using Xshell or attempt to obtain the password for logging in to a Windows BMS, you must use the .pem private key for authentication. To save the private key in .ppk format, perform the following operations:

      1. On the PuTTY Key Generator page, choose Conversions > Export OpenSSH key.
        CAUTION:

        If you use this private file to obtain the password for logging in to a Windows BMS, when you choose Export OpenSSH key, do not configure Key passphrase. Otherwise, obtaining the password will fail.

      2. Save the private key, for example, kp-123.pem, in a local directory.

  4. After the public key file and private key file are saved, import the public key to the system by referring to Import a Key Pair.

Import a Key Pair

If you store a public key by clicking Save public key of PuTTYgen, the format of the public key content will change. Such a key cannot be imported to the management console. To resolve this issue, obtain the public key content in correct format and import the content to the management console. For details, see What Do I Do If a Key Pair Created Using PuTTYgen Cannot Be Imported to the Management Console?

  1. Log in to the management console.
  2. Under Computing, click Bare Metal Server.

    The BMS console is displayed.

  3. In the navigation tree, choose Key Pair.
  4. On the right side of the page, click Import Key Pair.
  5. Use either of the following methods to import the key pair:
    • Selecting a file
      1. On the Import Key Pair page of the management console, click Select File and select the local public key file, for example, the .txt file saved in 2.
        NOTE:

        When importing a key pair, ensure that the public key is imported. Otherwise, importing the key pair will fail.

      2. Click OK.

        After the public key is imported, you can change its name.

    • Copying the public key content
      1. Copy the content of the public key in .txt file into the Public Key Content text box.
      2. Click OK.

Delete a Key Pair

If you no longer need a key pair, you can delete it. After a key pair is deleted, it cannot be restored. However, you can still use the private key saved locally to log in to the BMS, and the deleted key pair is still displayed in the BMS details.

NOTE:
  • If your key pair has been bound to a BMS and you do not unbind the key pair from the BMS before deleting the key pair, you cannot create a key pair of the same name. When you enter this name when creating or importing a key pair, the console displays an error message indicating that the key pair already exists.
  • If your key pair is not bound to any BMS or has been unbound from the BMS before it is deleted, you can create a key pair of the same name.
  1. Log in to the management console.
  2. Under Computing, click Bare Metal Server.

    The BMS console is displayed.

  3. In the navigation tree, choose Key Pair.
  4. Locate the row that contains the target key pair and click Delete in the Operation column.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback