You can specify an SSH key pair when you create an instance, or bind an SSH key pair to the instance after the instance is created. This topic describes how to bind an SSH key pair to an ECS instance after the instance is created. If your ECS instance originally adopts password-based authentication, the password-based authentication is automatically disabled after the key pair is bound.

Background information

Each ECS instance can be bound with only one SSH key pair. If the ECS instance has already been bound with an SSH key pair, the new SSH key pair replaces the original one after the new SSH key pair is bound.

Procedure

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Network & Security > SSH Key Pairs.
  3. In the top navigation bar, select a region.
  4. Find the key pair to be bound and click Bind in the Actions column.
  5. Select the target ECS instance in the Select Instance section, and then click the > icon to move the target instance to the Selected section.
    If instance names in the Select Instance section are dimmed, the instances are Windows instances and cannot be bound with SSH key pairs.
  6. Click OK.
  7. If the selected ECS instance is in the Running (Running) state, complete the following operations to restart the instance to make the binding operation take effect:
    1. In the left-side navigation pane, choose Instances & Images > Instances.
    2. Find the target instance, and choose More > Instance Status > Restart in the Actions column.
    3. In Restart Instance dialog box that appears, click OK.

What to do next

  • After an SSH key pair is bound to an ECS instance, you can log on to the ECS instance by using the SSH key pair. For more information, see Connect to a Linux instance by using an SSH key pair.
  • If you want to log on to the instance by using the password after you bind a key pair, you can reset the instance password. Then, you can log on to the instance by using the key pair or the new password. For more information, see Reset the logon password of an instance.