All Products
Search
Document Center

Elastic Compute Service:Bind an SSH key pair

Last Updated:Mar 15, 2024

You can specify an SSH key pair when you create an Elastic Compute Service (ECS) instance, or bind an SSH key pair to the instance after the instance is created. You can use SSH key pairs to establish secure connections to ECS instances and facilitate multi-user access management. You can also batch bind SSH key pairs or configure SSH key pairs to be automatically bound. This topic describes how to bind an SSH key pair to one or more ECS instances after the ECS instances are created.

Limits

In the ECS console, you can bind only one SSH key pair to an instance but can bind an SSH key pair to multiple instances.

  • If you bind an SSH key pair to an instance to which another SSH key pair is already bound, the new key pair replaces the original key pair.

  • If you bind an SSH key pair to an instance that uses password-based authentication, password-based authentication is automatically disabled for the instance after the key pair is bound.

Note

For Linux instances, the public key information of key pairs is stored in the ~/.ssh/authorized_keys file. You can modify the file to add or replace multiple SSH key pairs for an instance. For more information, see Add or replace an SSH key pair.

Bind an SSH key pair to an instance

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. Find the instance to which you want to bind an SSH key pair. In the Actions column, choose image> Instance Attributes > Bind Key Pair.

  5. Select a key pair from the Select Key Pair drop-down list and click OK.

  6. Start or restart the instance for the SSH key pair to take effect.

    • If the instance is in the Stopped state, start the instance for the SSH key pair to take effect. For more information, see Start an instance.

    • If the instance is in the Running state, click Restart Now to restart the instance. After the instance is restarted, the SSH key pair takes effect.

Bind an SSH key pair to multiple instances at a time

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Network & Security > Key Pairs.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. Find the SSH key pair that you want bind and click Bind in the Actions column.

  5. In the Selected ECS Instance column, select the instances to which you want to bind the SSH key pair and click the > icon to move the instances to the Selected column.

    Note

    If an instance name in the Select ECS Instance column is dimmed, the instance is a Windows instance and does not support SSH key pairs.

  6. Click OK.

  7. Start or restart the instances for the SSH key pair to take effect.

    • If an instance is in the Running state, restart the instance for the key pair to take effect. For more information, see Restart an instance.

    • If an instance is in the Stopped state, start the instance for the key pair to take effect. For more information, see Start an instance.

References