Help Center/ Elastic Cloud Server/ Troubleshooting/ SSH Connection Issues/ Why Does sshd Fail to Be Started on a Linux ECS?
Updated on 2023-03-30 GMT+08:00

Why Does sshd Fail to Be Started on a Linux ECS?

Symptom

The sshd service fails to be started on a Linux ECS, and /var/empty/sshd cannot be accessed.

Scenarios

The operations described in this section apply to ECSs running CentOS 7 or EulerOS. For other Linux OSs, the operations may be different.

Cause 1: Owner of /var/empty/sshd Is Not root

  1. The sshd service fails to be started, and the journal log records "/var/empty/sshd must be owned by root and not group or world-writable."

    # journalctl -xe

  2. Check the owner of the /var/empty/sshd file.

    # ll /var/empty/sshd

    As shown in the preceding figure, the owner of the /var/empty/sshd file is not root.

  3. Modify the owner and permissions of the /var/empty/sshd file.

    # chown -R root.root /var/empty/sshd

    # chmod -R 711 /var/empty/sshd

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

    # systemctl restart sshd

Cause 2: /var/empty/sshd Does Not Exist

  1. Run the following command to query the failure causes:

    journalctl -xe

  2. As shown in the preceding figure, the sshd service fails to be started because the /var/empty/sshd file does not exist. Run the following command to manually create the file:

    # mkdir -p /var/empty/sshd

  3. Restart the sshd service.

    # systemctl restart sshd