All Products
Search
Document Center

Simple Application Server:Connect to a Linux server

最終更新日:Oct 22, 2024

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

Prerequisites

  • The Linux simple application server to which you want to connect is in the Running state.

  • If you want to use a password to connect to a server, make sure that a password is configured for the server.

    After you create a simple application server, no password is configured for the root user by default. You must manually configure a password. For more information, see Set or reset the password of a server.

Precautions

If the feature of key pair-based logon is enabled for your Linux server, password-based logon is automatically disabled for the root account of the server.

Important

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

You can use Workbench in the Simple Application Server console to connect to a Linux server. You can also use a third-party client to connect to a Linux server. You can choose different methods to connect to your Linux server based on the operating system type of your on-premises device.

(Recommend) Method 1: Use Workbench to connect to a Linux server

You can use Workbench to connect to a simple application server in the Simple Application Server console. You can select one of the following connection methods based on your business requirements:

  • Connect with one-click on Workbench: By default, the admin user connects to the server over port 22 without entering a username and password. In this case, features such as file processing that require root user permissions cannot be used.

  • Password-based logons on Workbench: By default, the root user connects to the server over port 22 after the root user enters the password.

  • Rescue logon: This method is suitable for logging on to a Linux server when the server is running but the operating system is not booted.

    Note

    If you use the method of connecting with one-click on Workbench or password-based logons on Workbench, you can set a custom port for the connection. For more information, see Modify the remote connection port of a Linux server.

Procedure:

  1. Log on to the Simple Application Server console.

  2. In the left-side navigation pane, click Servers.

  3. In the server card, click Connect to connect to the server.

    You can also click the server ID in the server card to connect to the server on the Remote Connection tab.

  4. In the Connect dialog box, select a connection method based on your business requirements.

    1. Select remote connection method.

      Connect to the server as the admin user without entering a password

      In the Connect with One-click on Workbench section, click Log on Now to connect to the server as the admin user. You do not need to enter the username and password.

      image

      Connect to the server as the root user

      Click Log on By using Other Methods. In the Password-based Logons on Workbench section, click Log on Now and then enter the password of the root user to connect to the server.

      image

      Connect to the server by using the rescue feature

      You can use this method to connect to a Linux server that is in the Running state but whose operating system is not booted.

      1. Click Log on by Using Other Methods. In the Rescue Logon section, click Log on Now to connect to the server.

        image

      2. In the command line, enter root and the logon password.

  5. (Optional) Use Workbench to manage files on a Linux server.

    If you connect to a Linux server as the root user, Workbench provides a GUI to allow you to manage files on the Linux server. You can use Workbench to view, add, delete, and modify files on the Linux server. You can also use Workbench to upload and download files on the Linux server. For more information, see Manage files.

Method 2: Connect to a Linux server from a Windows device

This section describes how to connect to a Linux server from a Windows device. In this example, PuTTY is used.

Connect to a Linux server by using the system user and password

  1. Configure a logon password for the Linux server. For more information, see Set or reset the password of a server.

  2. Download and install PuTTY on your Windows device. For information about how to download and install PuTTY, see PuTTY: a free SSH and Telnet client.

  3. Start PuTTY.

  4. Configure the Linux server to which you want to connect.

    The following table describes the parameters that you must configure. Use the default values for parameters that are not described in the following table.

    Parameter

    Description

    Host Name(or IP address)

    Enter the logon account and public IP address of the simple application server. Format: <Username>@<Public IP address>. Example: root@121.40.XX.XX.

    Port

    Enter 22.

    Connection type

    Select SSH.

    Saved Sessions

    Enter a name, such as test, that is easy to identify, and then click Save to save the session. You do not need to enter information such as the public IP address of the server next time you log on to the server.

    putty configuration

  5. Click Open.

  6. In the command line, enter root, which is the system user of the Linux server. Then, press the Enter key.

  7. In the command line, enter the logon password of the root user of the Linux server and press the Enter key.

    Note

    For data security purposes, no output is returned when you enter a password. You only need to enter the correct password and press the Enter key.

    If the information shown in the following figure is displayed, the logon to the server is successful.login

Connect to a Linux server by using a key pair

  1. Bind a key pair to the Linux server. For more information, see Create or import a key pair.

    Important

    After you create a key pair, you must restart the server to allow the key pair to take effect.

  2. Download and install PuTTYgen and PuTTY.

  3. Convert the .pem private key file to the .ppk private key file.

    If the key file in the .pem format bound to your Linux server is automatically generated by Alibaba Cloud, you must convert the key file from the .pem format to the .ppk format before you can use PuTTY to connect to the server. Procedure:

    1. Open PuTTYgen. In the Actions section, click Load.puttygen

    2. In the lower part of the Load private key dialog box, select All Files(*.*) to view files of all formats.All Files

    3. Find and select the private key file stored in the .pem format on your on-premises device. In the PuTTYgen Notice message, click Yes.

    4. In the Parameters section, click RSA.

    5. 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 save the file.

  4. Configure the Linux server to which you want to connect.

    The following table describes the parameters that you must configure. Use the default values for parameters that are not described in the following table.

    Parameter

    Description

    Host Name(or IP address)

    Enter the logon account and public IP address of the simple application server. Format: <Username>@<Public IP address>. Example: root@121.40.XX.XX.

    Port

    Enter 22.

    Connection type

    Select SSH.

    Saved Sessions

    Enter a name, such as test, that is easy to identify, and then click Save to save the session. You do not need to enter the information such as the public IP address of the server next time you log on to the server.

    putty configuration

  5. Configure the private key file used for authentication.

    1. In the left-side navigation pane, choose Connection > SSH > Auth > Credentials.

    2. In the Private key file for authentication section, click Browse…

    3. Select the key file in the .ppk format on your on-premises device and click Open.image..png

  6. Click Open.

    If the information shown in the following figure is displayed, the connection to the server is successful.

    login

Method 3: Connect to a Linux server from a Linux or macOS device

This section describes two methods that can be used to connect to a Linux server. In these examples, the operating systems that support SSH commands are used.

Connect to a Linux server by using the system user and password.

  1. (Optional) Configure a logon password for the Linux server. For more information, see Set or reset the password of a server.

  2. Run the following command to connect to the Linux server:

    ssh root@<Public IP address of the Linux server>

    Example:

    ssh root@121.40.XX.XX
  3. Enter yes and press the Enter key.

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

  4. Enter the logon password of the Linux server and press the Enter key.

    Note

    For data security purposes, no output is returned when you enter a password. You need only to enter the correct password and then press the Enter key.

Connect to a Linux server by using a key pair

  1. Bind a key pair to the Linux server. For more information, see Create or import a key pair.

    Important

    After you create a key pair, you must restart the server to allow the key pair to take effect.

  2. Find the private key file stored on your on-premises device.

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

  3. 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
  4. 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 your Linux server and the actual path of your private key file.

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

    If the following command output is returned, run the ssh -o PubkeyAcceptedKeyTypes=+ssh-rsa root@<Public IP address of the Linux server> -i /test/XXX.pem command.

    sign_and_send_pubkey: no mutual signature supported root@47.110.XX.XX: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)  

Re-enable password-based logons

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. Procedure:

  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:

    sudo vim /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 command output after the modification.配置文件

  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 the SSH service:

    sudo service sshd restart

    After SSH is restarted, you can use the root account and the corresponding password to connect to the Linux server. If you did not configure a password or forget the password of the server, configure or reset the password. For more information, see Set or reset the password of a server.

    Important

    When you use a password to connect to the server, make sure that you enter the correct password.

FAQ

For information about how to troubleshoot an issue such as a timeout or failure that occurs when you connect to a server, see FAQ. If the issue persists, you can submit a ticket to obtain technical support.