• Elastic Cloud Server

ecs
  1. Help Center
  2. Elastic Cloud Server
  3. User Guide
  4. ECS Logins
  5. Logging In to a Linux ECS
  6. Login Using an SSH Key

Login Using an SSH Key

Prerequisites

  • You have obtained the private key file used during ECS creation.
  • You have bound an EIP to the ECS. For details, see section Viewing ECS Details.
  • You have configured the inbound rules of the security group. For details, see section Configuring Security Group Rules.
  • The network connection between the login tool (PuTTY) and the target ECS is normal. For example, the default port 22 is not blocked by the firewall.

Logging In to the Linux ECS from a Windows Computer

To log in to the Linux ECS from a Windows computer, perform the operations described in this section.

Method 1: Use PuTTY to log in to the ECS.

The following procedure uses PuTTY as an example. Before logging in to the ECS using PuTTY, make sure that the private key file has been converted to .ppk format.
  1. Check whether the private key file has been converted to .ppk format.
    • If yes, go to step 7.
    • If no, go to step 2.
  2. Visit the following website and download PuTTY and PuTTYgen:

    http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

    NOTE:

    PuTTYgen is a private key generator, which is used to create a key pair that consists of a public key and a private key for PuTTY.

  3. Run PuTTYgen.
  4. In the Actions area, click Load and import the private key file that you stored during ECS creation.

    Ensure that the format of All files (*.*) is selected.

  5. Click Save private key.
  6. Save the converted private key, for example, kp-123.ppk, to the local computer.
  7. Double-click PUTTY.EXE. The PuTTY Configuration page is displayed.
  8. Choose Connection > Data. Enter the image username in Auto-login username.
    NOTE:
    • If a public image is used, see Public Images Introduction for the image username.
    • If a private image is used, use the username of the private image.
  9. Choose Connection > SSH > Auth. In the last configuration item Private key file for authentication, click Browse and select the private key converted in step 6.
  10. Choose Session and enter the EIP of the ECS under Host Name (or IP address).
    Figure 1 Configuring the EIP
  11. Click Open.

    Log in to the ECS.

Method 2: Use Xshell to log in to the ECS.

  1. Start the Xshell tool.
  2. Run the following command using the EIP to remotely log in to the ECS through SSH:

    ssh Username@EIP

    An example is provided as follows:

    ssh root@192.168.0.1

  3. (Optional) If the system displays the SSH Security Warning dialog box, click Accept & Save.
    Figure 2 SSH Security Warning
  4. Select Public Key and click Browse beside the user key text box.
  5. In the user key dialog box, click Import.
  6. Select the locally stored key file and click Open.
  7. Click OK to log in to the ECS.

Logging In to the Linux ECS from a Linux Computer

To log in to the Linux ECS from a Linux computer, perform the operations described in this section. The following procedure uses private key file kp-123.pem as an example to log in to the ECS. The name of your private key file may differ.
  1. On the Linux CLI, run the following command to change operation permissions:

    chmod 400 /path/kp-123

    NOTE:

    In the preceding command, path refers to the path where the key file is saved.

  2. Run the following command to log in to the ECS:

    ssh -i /path/kp-123 Default username@EIP

    For example, if the default username is linux, run the following command:

    ssh -i /path/kp-123 linux@EIP

    NOTE:

    In the preceding command:

    • path is the path where the key file is saved.
    • EIP is the EIP bound to the ECS.