Help Center/ Elastic Cloud Server/ User Guide/ Instances/ Logging In to a Linux ECS/ Logging In to a Linux ECS from a macOS Server
Updated on 2025-02-19 GMT+08:00

Logging In to a Linux ECS from a macOS Server

Scenario

This section describes how to log in to a Linux ECS from a macOS server.

Prerequisites

  • The target ECS is running.
  • If you choose the password-based SSH login, the Login Mode has been set to Password during the ECS purchase process and the username and password for logging in to the Linux ECS have been obtained.

    If the password is forgotten, reset the password by referring to Resetting the Password for Logging In to an ECS on the Management Console.

  • If you choose the key pair-based SSH login, the Login Mode has been set to Key pair during the ECS purchase process and the private key file of the Linux ECS has been obtained.

    The private key file of the Linux ECS is generated during the key pair creation. If the private key file is lost, you can reset the key pair to assign a new key pair to the ECS. If you select I agree to host the private key of the key pair, you can export the managed private key as required. For details, see Exporting a Private Key.

  • You have bound an EIP to the ECS. For details, see Binding an EIP.

Procedure

You can log in to the Linux ECS through the terminal included in the macOS.

  • Using an SSH password
    1. Open the terminal of the macOS and run the following command to log in to the ECS:

      ssh Username@EIP

      If a public image is used (including CoreOS), the username is root.

  • Using an SSH key
    1. Open the terminal of the macOS and run the following command to change permissions. The following operations use private key file kp-123.pem as an example. Replace it with your actual private key file.

      chmod 400 /path/kp-123.pem

      The private key file of the Linux ECS is generated during the key pair creation. If the private key file is lost, you can reset the key pair to assign a new key pair to the ECS. If you select I agree to host the private key of the key pair, you can export the managed private key as required. For details, see Exporting a Private Key.

      In the preceding command, path refers to the path where the key file is saved.

    2. Run the following command to log in to the ECS:

      ssh -i /path/kp-123.pem Username@EIP

      • The username is core for a CoreOS public image.
      • The username is root for a non-CoreOS public image.

Follow-up Procedure

  • After logging in to the ECS using the SSH key, you can set a password (by using the passwd command) to log in to the Linux ECS using VNC.