All Products
Search
Document Center

Elastic Compute Service:Connect to a Linux instance by using a password

Last Updated:Jul 26, 2023

This topic describes how to use a username and password to connect to an Elastic Compute Service (ECS) Linux instance from a Windows, Linux, macOS, Android, or iOS device.

Prerequisites

  • A Linux instance is created.

  • A logon password is set for the instance.

  • A public IP address or an elastic IP address (EIP) is associated with the instance.

  • The instance is in the Running state.

  • The following rules are added to the security group to which the instance belongs. For more information, see Add a security group rule.

    Network type

    NIC type

    Rule direction

    Policy

    Protocol type

    Port range

    Priority

    Authorization type

    Authorization object

    Virtual Private Cloud (VPC)

    N/A

    Inbound

    Allow

    SSH (22)

    22/22

    1

    IPv4 CIDR blocks

    0.0.0.0/0

    Classic network

    Public

Background information

You can use one of the following methods based on the operating system of your device to connect to a Linux instance with a username and password:

Use a username and password to connect to a Linux instance from a Windows device

This section describes how to use a username and password to connect to a Linux instance from a Windows device. In this example, PuTTY is used.

  1. Download and install PuTTY.

    Download link: PuTTY.

  2. Start PuTTY.

  3. Configure required parameters to connect to the Linux instance.

    • Host Name (or IP address): Specify the public IP address or EIP of the instance.

    • Port: Enter 22.

    • Connection type: Select SSH.

    • Saved Sessions: optional. Enter a name that is easy to identify and click Save to save the session. This way, you do not need to enter session information, such as the public IP address of the instance, the next time you connect to the instance.Saved Session

    Note

    To prevent the PuTTY connection from closing due to timeout, we recommend that you click Connection in the Category section and set Seconds between keepalives (0 to turn off) to 60, which indicates that the server sends a message to the client every 60 seconds (equivalent to 1 minute) to maintain the connection. The default value of Seconds between keepalives (0 to turn off) is 0.

  4. Click Open.

    The first time you connect to the instance, the PuTTY Security Alert message appears. This message indicates that PuTTY cannot verify the authenticity of the remote server (instance) and can provide only the public key fingerprint of the server instead. Click Yes to indicate that you trust this server. PuTTY then adds the public key fingerprint to the registry of your device.

    Note

    If the PuTTY Security Alert message appears the next time you connect to the instance, the instance may suffer from man-in-the-middle attacks. For more information about alerts, see official PuTTY documentation.

    PuTTY无法确认远程服务器(实例)的真实性
  5. Enter the username and press Enter. The default username is root.

  6. Enter the logon password for the instance and press the Enter key.

    The characters of the password are hidden when you enter the password. After you enter the password, press the Enter key.

    If the Welcome to Alibaba Cloud Elastic Compute Service ! message appears, you are connected to the instance.

    If the error message Disconnected:No supported authentication methods available appears, username-password-based authentication is disabled in the instance or the public key of the key pair is not added to the .ssh/authorized_keys file of the authenticating user. For more information, see What do I do if the error message "No supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic)" appears when I connect to a Linux instance by using a third-party SSH client?

Use a username and password to connect to a Linux instance from a Linux or macOS device

  1. Run the following SSH command:

    ssh root@<Public IP address or EIP of the instance>

    Example command:

    ssh root@47.99.XX.XX
  2. Enter the logon password for the instance.

    If the Welcome to Alibaba Cloud Elastic Compute Service ! message appears, you are connected to the instance.