Fixing the ‘Failed to Start OpenSSH Server Daemon’ Issue
In some instances of Linux systems running on an ECS instance, the SSH service (sshd.service) fails to start, resulting in the error message “Failed to start OpenSSH server daemon.” This issue is often caused by the SSH service port (port 22) being occupied by another service.
To resolve this problem, you can either modify the port number of the service occupying port 22 or change the SSH service port according to your business needs. You can remotely connect to the ECS instance via VNC and use commands such as “/sbin/sshd -d” to check if port 22 is occupied by running services like Nginx. Based on your specific situation, you can choose to modify the port number of the Nginx service or the SSH service to resolve the issue.
Key Takeaways:
- Failed to start OpenSSH server daemon can occur when port 22 is occupied by another service.
- You can modify the port number of the service occupying port 22 or change the SSH service port.
- Use commands such as “/sbin/sshd -d” to check if port 22 is occupied.
- If Nginx is using port 22, modify its port number in the nginx.conf file and restart the Nginx service.
- If SSH service is using port 22, modify its port number in the sshd_config file and restart the SSH service.
Modifying the Nginx Service Port Number
If you determine that the port 22 is occupied by the Nginx service, you can modify the Nginx service port number to resolve the issue. To do this, you need to open the nginx.conf configuration file using the command “vim /etc/nginx/nginx.conf” and change the port number occupied by Nginx to a different value, such as 80. Save the changes by pressing the Esc key, typing “:wq“, and pressing Enter. Then, restart the Nginx service with the command “systemctl restart nginx” and the SSH service with the command “systemctl restart sshd.service“. This should free up port 22 and allow the SSH service to start successfully.
Modifying the Nginx Service Port Number
If you determine that the port 22 is occupied by the Nginx service, you can modify the Nginx service port number to resolve the issue. To do this, you need to open the nginx.conf configuration file using the command “vim /etc/nginx/nginx.conf” and change the port number occupied by Nginx to a different value, such as 80. Save the changes by pressing the Esc key, typing “:wq”, and pressing Enter. Then, restart the Nginx service with the command “systemctl restart nginx” and the SSH service with the command “systemctl restart sshd.service”. This should free up port 22 and allow the SSH service to start successfully.
If you determine that the port 22 is occupied by the Nginx service, you can modify the Nginx service port number to resolve the issue.
To do this, you need to open the nginx.conf configuration file using the command “vim /etc/nginx/nginx.conf” and change the port number occupied by Nginx to a different value, such as 80.
Save the changes by pressing the Esc key, typing “:wq“, and pressing Enter. Then, restart the Nginx service with the command “systemctl restart nginx” and the SSH service with the command “systemctl restart sshd.service“. This should free up port 22 and allow the SSH service to start successfully.
Here is an example of the configuration file before modification:
Location | Contents | ||
---|---|---|---|
/etc/nginx/nginx.conf |
|
After modifying the port number to 80, the configuration file will look like this:
Location | Contents | ||
---|---|---|---|
/etc/nginx/nginx.conf |
|
Modifying the SSH Service Port Number
If you determine that the SSH service itself is using port 22 and causing the “Failed to start OpenSSH server daemon” issue, don’t worry! You can easily resolve this by modifying the SSH service port number.
To get started, open the sshd_config configuration file by running the command ”
1 | vim /etc/ssh/sshd_config |
“. This will open the file in the Vim text editor.
Next, locate the line that specifies the port number for the SSH service. It should look something like ”
1 | #Port 22 |
“. Remove the ‘#’ symbol and change the port number to a different value, such as 2222. Save your changes by pressing the Escape key, typing “:wq”, and then hitting Enter.
After modifying the SSH service port number, you need to restart the SSH service for the changes to take effect. Simply run the command ”
1 | systemctl restart sshd.service |
“. This will restart the SSH service using the new port number you specified.
With the SSH service now running on the new port number, you should no longer encounter the “Failed to start OpenSSH server daemon” error. You can now connect to your ECS instance using the modified port number and resume your normal operations.
FAQ
What is the possible cause of the “Failed to start OpenSSH server daemon” error message on Linux systems running on an ECS instance?
This error message is often caused by the SSH service port (port 22) being occupied by another service.
How can I resolve the “Failed to start OpenSSH server daemon” issue?
To resolve this problem, you can either modify the port number of the service occupying port 22 or change the SSH service port according to your business needs.
How can I check if port 22 is occupied by running services like Nginx?
You can remotely connect to the ECS instance via VNC and use commands such as “/sbin/sshd -d” to check if port 22 is occupied by running services like Nginx.
What should I do if port 22 is occupied by the Nginx service?
If port 22 is occupied by the Nginx service, you can modify the Nginx service port number to resolve the issue.
How can I modify the Nginx service port number?
To modify the Nginx service port number, open the nginx.conf configuration file using the command “vim /etc/nginx/nginx.conf” and change the port number occupied by Nginx to a different value, such as 80. Save the changes and restart the Nginx service with the command “systemctl restart nginx”.
What should I do if the SSH service itself is using port 22?
If the SSH service itself is using port 22, you can modify the SSH service port number to resolve the issue.
How can I modify the SSH service port number?
To modify the SSH service port number, open the sshd_config configuration file using the command “vim /etc/ssh/sshd_config” and change the port number of the SSH service to a different value, such as 2222. Save the changes and restart the SSH service with the command “systemctl restart sshd.service”.
- About the Author
- Latest Posts
Mark is a senior content editor at Text-Center.com and has more than 20 years of experience with linux and windows operating systems. He also writes for Biteno.com