All Products
Search
Document Center

Elastic Compute Service:What do I do if I cannot connect to a Linux instance because SSH is not started?

Last Updated:Feb 13, 2025

When you connect to a Linux Elastic Compute Service (ECS) instance over SSH, make sure that the SSH service is started on the instance. If the SSH service is not started on the instance, you cannot connect to the instance over SSH. This topic describes how to view the status of the SSH service and start the service.

Problem description

You cannot connect to a Linux ECS instance over SSH. You connect to the instance by using Virtual Network Computing (VNC) and run the systemctl status sshd.service command to check the status of the SSH service (sshd.service). If inactive (dead) is displayed in the command output, the SSH service is not started. As a result, you cannot connect to the instance over SSH.

查看sshd服务状态

Cause

The SSH service may not be started due to various reasons. For example, the sshd process is not configured to automatically start on system startup, the owner or group to which a critical sshd directory belongs is incorrectly configured, the SSH configuration file is abnormal, the PATH environment variable is incorrectly configured, or the required port is occupied.

Solution

  1. Connect to the ECS instance by using VNC.

    For more information, see Connect to an instance by using VNC.

  2. Run the following command to check the status of the SSH service:

    systemctl status sshd.service

    The following command output indicates that the sshd.service process is not started.

    查看sshd服务状态

  3. Run the following commands to start the SSH service and configure the service to automatically start on system startup:

    sudo systemctl start sshd.service
    sudo systemctl enable sshd.service

    If an error message appears when you start the SSH service, you can resolve the issue based on the error message. For information about how to resolve the issue that the SSH service cannot be started, see the following topics: