Binding a Key Pair to an ECS
If you set the login mode to Password when purchasing an ECS running Linux, and you need to change the login mode to Key Pair, you can bind the key pair to the ECS on the KPS console, KPS will configure the key pair. After the key pair is bound, you can use the private key to log in to the ECS.
Operation
Table 1 describes the operation guide.
Operation |
Application Scenario |
Prerequisites |
Constraints |
---|---|---|---|
Binding a key pair |
Log in to the ECS using a key pair. |
|
|
You can view the key pair information on the KPS console, including the name, fingerprint, and private key. |
- |
- |
|
If the private key is lost, use a new key pair to bind to the ECS. |
|
- |
|
If your private key is leaked, you must replace the public key of the ECS with a new key pair. After the replacement, only the new private key can be used for authentication — the original private key will no longer grant access. |
|
- |
|
If you no longer want to use a key pair to log in to an ECS, change the login mode to password. |
|
|
Binding a Key Pair
- Log in to the DEW console.
- Click
in the upper left corner of the console and select a region or project.
- In the navigation pane on the left, click Key Pair Service.
- Click ECS List to view ECSs.
- Locate the target ECS and click Bind in the Operation. The Bind Key Pair dialog box is displayed.
- If the ECS is shut down, a dialog box will be displayed, as shown in Figure 1.
- If the ECS is running, you need to provide the root password, as shown in Figure 2.
- If you have the root password of the ECS, you can directly enter the password to bind the key pair to the ECS.
- If you do not have the root password of the ECS, you can shut it down, and bind the key pair when the ECS is in Shut down state.
- Select a new key pair from the drop-down list box of New Key Pair.
- The default port number is 22 and can be modified.
Before using user-defined port, ensure that:
- The key pair can be connected to the ECS using the port. For details about how to modify the security group configuration of an ECS, see Configuring Security Group Rules.
- Modify the default port of the ECS and ensure that the port is enabled. For details, see Enhancing Security for SSH Logins to Linux ECSs.
- Modify the default port of the ECS and ensure that the port is enabled.
- You can choose whether to disable the password login mode as necessary. By default, the password login mode is disabled.
- If you do not disable the password login mode, you can use the password or the key pair to log in to the ECS.
- If the password login mode is disabled, you can use only the key pair to log in to the ECS. If you need to use the password login mode later, you can enable the password login mode again. For details, see How Do I Enable the Password Login Mode for an ECS?.
- Read and select I have read and agree to the Key Pair Service Disclaimer.
- Click OK to complete the operation.
- If the ECS is not shut down, use the root password to bind the key pair. It takes about 30 seconds to complete.
- If the ECS is shut down, the binding operation may take about five minutes.
Binding Key Pairs in Batches
- Scenario 1: If the ECSs to be bound to a key pair share the same password, you can use one-click binding, that is, select the key pair to be bound to and enter the root password of the ECSs.
- Scenario 2: If the ECSs to be bound to a key pair use different root passwords, you need to use separate binding, that is, select the key pair to be bound to and enter the root password of each ECS.
- In the navigation pane on the left, click Key Pair Service.
- Click ECS List to view ECSs.
- Select the servers to be bound in batches and click Bind above the search box.
- If the passwords of the ECSs to be bound are the same, you can select a key pair by one click and enter the password to bind the key pair, as shown in Figure 3.
- If the passwords of the ECSs to be bound are different, you can bind them separately, as shown in Figure 4.
If you select Unified bind, only the same key pair can be used for binding.
Viewing a Key Pair
This section describes how to view the key pair information, including the names, fingerprints, and private keys on the KPS page of the DEW console.
- In the navigation pane on the left, click Key Pair Service.
- Click the Private Key Pairs tab and view information about the key pair in the key pair list.
The list describes the names, fingerprints, private keys, and statuses of key pairs.
- Click the name of the target key pair. The detailed information about the key pair and the list of ECSs using the key pair are displayed, as shown in Figure 5.
When you purchase an ECS and set login mode to Key Pair, the selected key pair is bound to the ECS.
Table 2 lists the parameters of the ECS to which the key pair is bound.
- Click ECS List to view ECSs.
Figure 6 ECS list
- Click the number next to
in the Status column to view the failed tasks, as shown in Figure 7.
Status of resetting or replacing the key pair:
: Executing
: Execution failed
- Locate the target failed key pair task and click Delete in Operation column. You can also click Delete All on top of the list to delete all failed tasks.
- Click Learn more to view related documents.
Resetting a Key Pair
If your private key is lost, you can use a new key pair to reconfigure the ECS through the management console. After resetting the key pair, you need to use the private key of the new key pair to log in to the ECS, and the original private key cannot be used to log in to the ECS.
- The ECS whose key pair is to be reset must use the public image provided by Huawei Cloud.
- To reset the key pair, you can replace the public key of the user by modifying the /root/.ssh/authorized_keys file on the server. Ensure that the file is not modified before resetting the key pair. Otherwise, the reset will fail.
- The ECS must be in the Shut down state.
- In the navigation pane on the left, click Key Pair Service.
- Click the ECS List tab, locate the target ECS in the list and click Reset in the Operation column. The key pair reset dialog box is displayed, as shown in Figure 8.
- Select a new key pair from the drop-down list box of New Key Pair.
- Click OK. The ECS key pair will be reset in about 10 minutes.
Replacing a Key Pair
If your private key is leaked, you can use a new key pair to replace the public key of the ECS through the management console. After replacing the key pair, you need to use the private key of the new key pair to log in to the ECS, and the original private key cannot be used to log in to the ECS.
- The ECS whose key pair is to be replaced uses the public image provided by Huawei Cloud.
- To replace the key pair, you can replace the public key of the user by modifying the /root/.ssh/authorized_keys file on the server. Ensure that the file is not modified before replacing the key pair. Otherwise, replacing the public key will fail.
- The ECS must be in the Running state.
- In the navigation pane on the left, click Key Pair Service.
- Click the ECS List tab, locate the target ECS in the list and click Replace in the Operation column. The key pair replacement dialog box is displayed, as shown in Figure 9.
- Select a new key pair from the drop-down list box of New Key Pair.
- Click Select File to upload the private key (in .pem format) of the original key pair or copy the private key content to the text box.
- The private key to be uploaded or copied to the text box must be in the .pem format. If it is in the .ppk format, convert it by referring to How Do I Convert the Format of a Private Key File?.
- Click OK. The key pair will be replaced in about one minute.
Unbinding a Key Pair
If you want to change the login mode from Key Pair to Password, unbind the key pair on the KPS console.
- In the navigation pane on the left, click Key Pair Service.
- Click the ECS List tab, locate the target ECS in the list, and click Unbind in the Operation column.
- If you unbind the key pair when the ECS is in the Running state, you need to upload the private key. Click Select file to upload the private key (in the .pem format) of the existing key pair or copy the private key to the text box. If the ECS is shut down, skip this step.
- The private key to be uploaded or copied to the text box must be in the .pem format. If it is in the .ppk format, convert it by referring to How Do I Convert the Format of a Private Key File?.
- Click OK. The key pair will be unbound from the ECS in about one minute.
To log in to the ECS, after you unbind the key pair, reset the password in time on the ECS console. For details, see Elastic Search Server User Guide.
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