All Products
Search
Document Center

"Main process exited, code = exited" error when the SSH service is started

Last Updated: Sep 21, 2020

Disclaimer: This article may contain information about third-party products. Such information is for reference only. Alibaba Cloud does not make any guarantee, express or implied, with respect to the performance and reliability of third-party products, as well as potential impacts of operations on the products.

 

Problem description

When you use the service or systemctl command to start the SSH service on an ECS instance in the Linux system, the command line does not return any error message, but the service does not run properly. Check the secure log and find the following error information.

sshd.service: main process exited, code=exited, status=203/EXEC.
init: ssh main process (1843) terminated with status 255.

 

Causes

This problem is typically caused by an exception in the PATH environment variable configuration, or the files related to the SSH software package have been removed.

 

Solution

Note: The configurations and descriptions in this article have been tested in the CentOS 6.5 64-bit operating system. The configurations of other Linux releases may be different. For more information, see the official documentation of the corresponding releases.

Follow these steps to check and solve the problem.

  1. PassManagement terminalEnter the system.
  1. Run the following command to configure environment variables:
    echo $PATH
    The command output is as follows, which is the default value of the PAHT environment variable.
    /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
  1. If the default value of the PATH environment variable is changed, run the following command to reset the variable.
    export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
  1. Run the following command to find and confirm the sshd program path.
    find / -name sshd
    The command output is as follows, indicating that the sshd program is included in the default path.
    /usr/sbin/sshd
  1. If the corresponding file does not exist, we recommend that you reinstall the SSH software package or upload a normal file from the outside through FTP.
  1. Run the following command to restart the SSH service.
    service sshd restart

Tips: If you have any questions, seeElastic Compute Service Linux SSH logon failure troubleshooting guideFurther troubleshooting and analysis.

 

Application scope

  • ECS