This topic explains how to resolve the "Failed to start OpenSSH server daemon" error, which can occur 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. Running the systemctl status sshd.service command to check the SSH service status returns the Failed to start OpenSSH server daemon error.

Cause
This issue occurs when the default SSH service port (22) is used by another application.
Solution
To resolve this issue, you can either change the conflicting service's port or the SSH service's port.
Connect to the Linux ECS instance using Virtual Network Computing (VNC).
For more information, see Choose an ECS remote connection method.
Start the SSH service in debug mode.
/sbin/sshd -dThe output indicates that the SSH service cannot start because port 22 is in use.

Check which process is using port 22.
ss -tunlp | grep 22The following output shows that the NGINX service is using port 22.
ImportantIn this example, the NGINX service uses port 22. Your actual port conflict may involve a different service.

Choose one of the following solutions.
Change the NGINX service port.
Open the
nginx.confconfiguration file.vim /etc/nginx/nginx.confChange the NGINX port to 80.

Press
Esc, enter:wq, and then pressEnterto save the file and exit.Restart the NGINX service.
systemctl restart nginxRestart the SSH service.
systemctl restart sshd.service
Change the SSH service port.
Open the
ssh_configconfiguration file.vim /etc/ssh/sshd_configChange the SSH service port, for example, to 2222.

Press
Esc, enter:wq, and then pressEnterto save the file and exit.Restart the SSH service.
systemctl restart sshd.service