How to use a key pair to log on to a Linux instance depends on the local operating system.

Note
You can use a password to connect to a Linux instance. For more information, see  Connect to a Linux instance by using a password and Connect to an instance by using the Management Terminal.

Windows OS

In this section, it is demonstrated how to use a key pair to log on to a Linux instance on a Windows system, using the popular SSH tools PuTTY and PuTTYgen as an example.

Prerequisites
  • PuTTY and PuTTYgen must have been installed. You can download them at:

  • You must have a Linux instance that has been bound to an instance. You can allocate an SSH key pair when creating an instance or  bind an SSH key pair to an instance.

  • Add the following rule in the security group to enable the access to the TCP Port 22 of the instance. For more information, see Add security group rules.
    Network Type NIC Rule Direction Authorization Policy Protocol Type Port Range Authorization Type Authorization Object Priority
    VPC N/A Inbound Allow SSH(22) 22/22 Address Field Access 0.0.0.0/0 1
    Classic Internet
Procedure
  1. Optional. If you are using a key pair generated by Alibaba Cloud, of which the private key is a .pem file, you must convert it to a .ppk file. If your private key is a .ppk file, you can skip this step.
    Note
    When you create an SSH key pair, download the .pem private key.
    1. Start PuTTYgen. In this example, we use PuTTYgen version 0.68.
    2. Under the > Type of key to generate option, select RSA.
      Note
      The value of Number of bits in a generated key can be left as is. The software automatically update the value based on the imported private key information.


    3. Click Load to find your .pem file.
      Note
      By default, PuTTYgen only displays files with an extension of .ppk.


    4. Select the downloaded private key file from Alibaba Cloud, or the ready private key file, and click Open.
    5. Click OK to close the confirmation dialog box.
    6. Click Save private key. PuTTYgen displays warning about saving the key without a password. Click Yes.
    7. Specify the same name for the private key with the key pair, and save the settings. PuTTY automatically adds the .ppk file.
  2. Start PuTTY.
  3. Select Connection > > SSH > > Auth.Click Browse… and select the .ppk file generated in Step 1.

  4. Click Session.
    • In Host Name (or IP address), enter your account and the public IP address of the instance to be connected to. The format is root@IP address.
    • In Port enter the port number 22.
    • For Connection type, select SSH.



  5. Click Open to start accessing your Linux instance.

When the window shows  Connection established., it indicates you have successfully logged on to the instance using the key pair.

Linux OS or other systems supporting SSH commands

In this section, it is demonstrated how to use a key pair to log on to a Linux instance on a Linux system or a system supporting SSH commands, such as MobaXterm for Windows.

Prerequisites

You must have a Linux instance that has been bound to an SSH key pair. You can allocate an SSH key pair when creating an instance , or bind an SSH key pair to an instance.

Add the following rule in the security group to enable the access to the TCP Port 22 of the instance. For more information, see Add security group rules.

Network Type NIC Rule Direction Authorization Policy Protocol Type Port Range Authorization Type Authorization Object Priority
VPC N/A Inbound Allow SSH(22) 22/22 Address Field Access 0.0.0.0/0 1
Classic Internet
Procedure
  1. Locate directory of your private key, for example, /root/xxx.pem.
    Note
    When you create an SSH key pair, download the .pem private key. xxx.pem is the private key file.
  2. To modify the attributes of the private key, run the command: chmod 400 [directory of the private key file]. For example, chmod 400 /root/xxx.pem.
  3. To connect to the instance, run the command ssh -i directory of the private key file] root@Internet IP address. For example, ssh -i /root/xxx.pem root@10.10.10.100.