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.
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.
Connect to the Linux ECS instance by using Virtual Network Computing (VNC).
For more information, see Methods for connecting to an ECS instance.
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.
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.
ImportantIn this example, the NGINX service is used. View the command output for the actual service that occupies the port.
Resolve the issue based on your business requirements.
Change the port number of the NGINX service.
Run the following command to open the nginx.conf configuration file:
vim /etc/nginx/nginx.conf
Change the port number of the NGINX service to 80.
Press the
Esc
key, enter:wq
, and then press theEnter
key to save and close the configuration file.Run the following command to restart the NGINX service:
systemctl restart nginx
Run the following command to restart the SSH service:
systemctl restart sshd.service
Change the port number of the SSH service.
Run the following command to open the ssh_config configuration file:
vim /etc/ssh/sshd_config
Change the port number of the SSH service to a value other than 22. Example: 2222.
Press the
Esc
key, enter:wq
, and then press theEnter
key to save and close the configuration file.Run the following command to restart the SSH service:
systemctl restart sshd.service