What should I do if the error "Failed to start OpenSSh server daemon" is displayed?
Problem Phenomenon
In the ECS instance of the Linux system, the SSH service (sshd.service) cannot be started. Run systemctl status sshd.service to view the SSH service, and the error "Failed to start OpenSSh server daemon" is displayed.
sshd status
Problem Causes
This problem may be caused by the SSH service port (22) being occupied.
Solution
You can solve this problem by modifying the port number of the service occupying port 22 or modifying the SSH service port according to business needs.
1. Remotely connect to the ECS instance via VNC.
2. Execute the following command to run the SSH service in test mode.
/sbin/sshd -d
The displayed information is as follows, indicating that port 22 is occupied, and the SSH service cannot be started.
3. Run the following command to check the usage of port 22.
ss -tunlp | grep 22
The displayed information is as follows, indicating that port 22 is occupied by the Nginx service.
Important The fact that port 22 is occupied by the Nginx service in this article is just an example, please refer to the actual situation.
Ngnix takes 22
4. You can choose an appropriate solution to solve this problem according to your needs.
4.1 Modify the Nginx service port number.
Execute the following command to open the nginx.conf configuration file.
vim /etc/nginx/nginx.conf
Change the port number occupied by Nginx to 80.
Modify the port occupied by Ngnix
After pressing the Esc key, type :wq and press Enter 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
4.2 Modify the SSH service port number.
Run the following command to open the ssh_config configuration file.
vim /etc/ssh/sshd_config
Change the port number of the SSH service, for example, to 2222.
Modify the port occupied by SSH
After pressing the Esc key, type :wq and press Enter to save and close the configuration file.
Run the following command to restart the SSH service.
Related Articles
-
6 Optional Technologies for Data Storage
Knowledge Base Team
Explore More Special Offers
-
Short Message Service(SMS) & Mail Service
50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00