This topic describes how to connect to a Linux server by using the Simple Application Server console or by using a third-party client.

Background information

You can use the Simple Application Server console to connect to a Linux server. For more information, see Connect to a Linux server by using the Simple Application Server console.

You can also use a third-party client to connect to a Linux server. The methods used to connect to a Linux server vary based on the operating systems of your local device. For more information, see the following topics:

Note that if key-based logon is enabled on a Linux server, password-based logon is automatically disabled for the root account on the server. To re-enable password-based logon, you must modify the configuration file. For more information, see Re-enable password-based logon.

Connect to a Linux server by using the Simple Application Server console

  1. Log on to the Simple Application Server console.
  2. In the left-side navigation pane, click Servers.
  3. Use one of the following methods to connect to a Linux server:
    • On the Servers page, find the server to which you want to connect and click the Connect icon icon in the server card to connect to the server. Connect to a server by using the Simple Application Server console 1
    • On the Servers page, click the card of the server to which you want to connect. In the upper-right corner of the Overview page, click Connect. Connect to a server by using the Simple Application Server console 2
    • On the Servers page, click the card of the server to which you want to connect. In the left-side navigation pane, choose Server Maintenance > Connect. Then, click Connect. Connect to a server by using the Simple Application Server console 3

Connect to a Linux server from a Windows device

This section describes the following methods used to connect to a Linux server from a Windows device. In the examples, PuTTY and PuTTYgen are used.

Method 1: Connect to a Linux server by using the system account and password

This method is applicable to Linux servers with a configured logon password. For more information, see Reset the logon password of a simple application server.

  1. Download and install PuTTY on your Windows device.
    To download PuTTY, see PuTTY: a free SSH and Telnet client.
  2. Start PuTTY.
  3. Configure the information of the Linux server to which you want to connect.
    Configure the following parameters:
    • Host Name(or IP address): Enter the public IP address of the Linux server. Example: 121.40.XX.XX.
    • Port. Enter 22.
    • Connection type: Select SSH.
    • Optional:Saved Sessions: Enter a name that is easy to identify and click Save to save the session. The next time you log on to the server, the saved session information such as the public IP address is automatically entered.
    putty configuration
  4. Click Open.
    When you connect to the instance for the first time, the PuTTY Security Alert message appears, which indicates that PuTTY cannot confirm the authenticity of the remote server and can provide only the public key fingerprint of the server. Click Yes to confirm that you trust this server. PuTTY then adds the public key fingerprint to the registry of the on-premises device.
    Note If the PuTTY Security Alert message appears the next time you log on to the instance, the instance may suffer from man-in-the-middle attacks. For more information, visit PuTTY User Manual.
    PuTTY cannot confirm the authenticity of the remote server (instance)
  5. On the command line, enter root, which is the system account of the Linux server. Then, press the Enter key.
  6. On the command line, enter the logon password that corresponds to the root account of the Linux server and press the Enter key.
    A welcome page similar to the following figure indicates that you are logged on to the server. login

Method 2: Connect to a Linux server by using a key pair

This method is applicable to Linux servers with a bound key pair. For more information, see Create a key pair.

  1. Convert the format of a private key file.
    If the key file bound to your Linux server is automatically generated by Alibaba Cloud in the .pem format, you must convert the key file from the .pem format to the .ppk format before you can use PuTTY to connect to the server. Perform the following operations:
    1. Download PuTTYgen to your Windows device.
      Click PuTTYgen to download PuTTYgen.
    2. Start PuTTYgen. In the Actions section, click Load.
      puttygen
    3. In the lower part of the Load private key: dialog box, select All Files(*.*) to view key files in all formats.
      All Files
    4. Find and select the private key file stored in the .pem format on your local device. In the PuTTYgen Notice message, click Yes.
    5. In the Parameters section, select RSA.
    6. In the Actions section, click Save private key. Then, click Yes.
      Specify a name for the private key file in the .ppk format and a path to which to save the file.
  2. Download and install PuTTY on your Windows device.
    To download PuTTY, see PuTTY: a free SSH and Telnet client.
  3. Start PuTTY.
  4. Configure the information of the Linux server to which you want to connect.
    Configure the following parameters:
    • Host Name(or IP address): Enter the public IP address of the Linux server. Example: 121.40.XX.XX.
    • Port. Enter 22.
    • Connection type: Select SSH.
    • Optional:Saved Sessions: Enter a name that is easy to identify and click Save to save the session. The next time you log on to the server, the saved session information such as the public IP address is automatically entered.
    putty configuration
  5. In the left-side navigation pane, choose Connection > SSH > Auth.
  6. In the Authentication parameters section, click Browse...
  7. Select the key file in the .ppk format on your local device, and then click Open.
    prvatekey
  8. Click Open.
    When you connect to the instance for the first time, the PuTTY Security Alert message appears, which indicates that PuTTY cannot confirm the authenticity of the remote server and can provide only the public key fingerprint of the server. Click Yes to confirm that you trust this server. PuTTY then adds the public key fingerprint to the registry of the on-premises device.
    Note If the PuTTY Security Alert message appears the next time you log on to the instance, the instance may suffer from man-in-the-middle attacks. For more information, visit PuTTY User Manual.
    PuTTY cannot confirm the authenticity of the remote server (instance)
  9. On the command line, enter root and press the Enter key.
    A welcome page similar to the following figure indicates that you are logged on to the server. login

Connect to a Linux server from a Linux or macOS device

This section describes two methods used to connect to a Linux server. In the examples, the operating systems that support SSH commands are used.
  • Method 1: Connect to a Linux server by using the system account and password

    This method is applicable to Linux servers with a configured logon password. For more information, see Reset the logon password of a simple application server.

    1. Run the following command to connect to a Linux server:
      ssh root@<public IP address of the Linux server>
      Sample command:
      ssh root@121.40.XX.XX
    2. Enter yes and press the Enter key.

      The first time you connect to the Linux server, the system cannot independently verify the authenticity of the server. The system instead provides you with the public key fingerprint of the server and asks you to confirm whether to continue with the connection. Enter yes to indicate that you trust the server.

    3. Enter the logon password that corresponds to the root account of the Linux server and press the Enter key.
  • Method 2: Connect to a Linux server by using a key pair

    This method is applicable to Linux servers with a bound key pair. For information about how to create a key pair for a server, see Create a key pair.

    1. Find the private key file stored on your local device.

      In this example, /test/XXX.pem key file is used.

    2. Run the following command to modify permissions on the private key file.

      Replace /test/XXX.pem with the actual path of the private key file.

      chmod 400 /test/XXX.pem
    3. Run the following command to connect to the Linux server.

      Replace <public IP address of the Linux server> and /test/XXX.pem with the actual public IP address of the Linux server and the actual path of the private key file.

      ssh root@<public IP address of the Linux server> -i /test/XXX.pem

Re-enable password-based logon

After you create a key pair for a simple application server and restart the server for the new key pair to take effect, password-based logon is automatically disabled for the root account on the server. To re-enable password-based logon, you must modify the configuration file of the server.

  1. Connect to the server by using the Simple Application Server console.
  2. Run the following command to open the /etc/ssh/sshd_config file:
    vi /etc/ssh/sshd_config
  3. Press the I key to enter the edit mode. At the end of the file, change PasswordAuthentication no to PasswordAuthentication yes.
    The following figure shows the modified configurations. Configuration file
  4. Press the Esc key to exit the edit mode. Then, enter :wq and press the Enter key to save and close the file.
  5. Run the following command to restart SSH:
    sudo service sshd restart
    After SSH is restarted, you can use the root account and its password to connect to the Linux server.