All Products
Document Center

Connect to a Linux OS server

Last Updated: Apr 20, 2021

We have two methods to remotely connect to the Linux OS instance:

Method 1: Connect by using the Remote Connection function on the Console.
Method 2: Connect by using the local SSH client. (Linux OS)

Connect by using the Remote Connection function on the Console

  • Prerequisites
    Port 22 of the server’s firewall is enabled, and the corresponding SSH service is alive and monitored on the server.

  • Connection method
    The Remote Connection function has three entries:

    • The Card label on the Server List page

    • The upper-right corner on the Server Details page

    • The Remote Connection function of Server O&M

Connect by using the local SSH client

The local environment is Windows

Prerequisites: You must download and installed PuTTY and PuTTYgen.

  • PuTTY download address
  • PuTTYgen download address
    Connect by using account and password
    Modify the root password, and then enter the IP address, account, and password, and connect by means of PuTTY.
    Connect by using a key
    Prerequisites: you have already created a key pair on the console, and key pair management requires a server restart on console to become active.
  1. (Optional) If you are using the .pem private key file generated by Alibaba Cloud, please convert the file into a .ppk private key file by referencing the following steps. If the private key file you are using is already a .ppk file, you can skip this section.

    1. Start PuTTYgen. In this example, the PuTTYgen version is 0.68.
    2. Choose Parameters > Type of key to generate, and select RSA. The value of Number of bits in a generated key can be left as is. The software will automatically update the value based on the imported private key information.
      ECS _ SSH Key Pair _ Import private key parameters
    3. Click Load. The PuTTYgen only displays files with a .ppk extension by default. To find your .pem file, select to display “All Files”.
      ECS _ SSH Key Pair _ Open the private key file to be imported
    4. Select the .pem private key file downloaded from Alibaba Cloud, and click Open.

    5. Click OK to close the confirmation dialog box.

    6. Click Save private key. PuTTYgen will display a warning about saving the key without a password. Click YES(Y).

    7. Specify the same name for the private key as the key pair, and save the modification. PuTTY will automatically add the .ppk extension for the file.

  2. Start PuTTY.

  3. Choose Connection > SSH > Auth, click Browse…, and then select the .ppk file generated in the previous step.
    ECS _ SSH Key Pair _ Auth

  4. Click Session.

    • Enter the account and the Internet IP address of the instance to be connected in Host Name (or IP address). The format is: “root@IP address”.
    • Enter 22 in Port.
    • Select SSH in Connection type.
      ECS _ SSH Key Pair _ Remote connection setup

Click Open to start connecting your Linux instance.

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

The local environment is Linux or supports SSH commands

Next, we will describe how to log on to a Linux instance by using an SSH key pair in a Linux environment or an environment that supports SSH commands (e.g. MobaXterm for Windows). The precondition is that you have already created a key pair on the console, and key pair management requires a server restart on console to become active.

Procedures are as follows:

  1. Find the directory of your downloaded private key file, e.g. /root/xxx.pem.
    xxx.pem is your private key file.

  2. Use the following command to modify the attribute of your private key file: chmod 400 xxx.pem.

  3. Use an SSH command to connect to the instance (let’s assume the Internet IP is ssh root@ -i /root/xxx.pem.

Restore account-password logon after enabling a key

After you have enabled a key, the server will disable the account-password logon method by default. If you want to use the account-password logon method, you must modify the configuration file.

  1. Remote server logon.

  2. Modify PasswordAuthentication no in /etc/ssh/sshd_config to PasswordAuthentication yes, and save the modification.

  3. Enter the following command sudo service sshd restart to restart the SSH service, then you will be able to connect to the server by using the account and password again.