All Products
Search
Document Center

Elastic Compute Service:What do I do if the "Failed to start OpenSSh server daemon" error message appears when I start the SSH service on a Linux ECS instance?

Last Updated:Mar 12, 2025

This topic describes the cause of and solution to the issue that the "Failed to start OpenSSh server daemon" error message appears when you start the SSH service on a Linux Elastic Compute Service (ECS) instance.

Problem description

The SSH service (sshd.service) fails to start on a Linux ECS instance. After you run the systemctl status sshd.service command on the instance, the "Failed to start OpenSSh server daemon" error message appears.

sshd状态

Cause

The preceding issue may occur because SSH port 22 is occupied by a different service.

Solution

To resolve the issue, change the port number of the service that occupies port 22 or change the port number of the SSH service to a value other than 22.

  1. Connect to the Linux ECS instance by using Virtual Network Computing (VNC).

    For more information, see Methods for connecting to an ECS instance.

  2. Run the following command to run the SSH service in debug mode:

    /sbin/sshd -d

    The following command output indicates that port 22 is occupied by a different service and the SSH service failed to be started.

    端口被占用

  3. Run the following command to identify the service that occupies port 22:

    ss -tunlp | grep 22

    The following command output indicates that port 22 is occupied by the NGINX service.

    Important

    In this example, the NGINX service is used. View the command output for the actual service that occupies the port.

    Ngnix占用22

  4. Resolve the issue based on your business requirements.

    • Change the port number of the NGINX service.

      1. Run the following command to open the nginx.conf configuration file:

        vim /etc/nginx/nginx.conf
      2. Change the port number of the NGINX service to 80.

        修改Ngnix占用端口

      3. Press the Esc key, enter :wq, and then press the Enter key to save and close the configuration file.

      4. Run the following command to restart the NGINX service:

        systemctl restart nginx 
      5. Run the following command to restart the SSH service:

        systemctl restart sshd.service 
    • Change the port number of the SSH service.

      1. Run the following command to open the ssh_config configuration file:

        vim /etc/ssh/sshd_config
      2. Change the port number of the SSH service to a value other than 22. Example: 2222.

        修改SSH占用端口

      3. Press the Esc key, enter :wq, and then press the Enter key to save and close the configuration file.

      4. Run the following command to restart the SSH service:

        systemctl restart sshd.service