All Products
Search
Document Center

:"main process exited, code=exited" error when SSH service is started

Last Updated:Apr 27, 2022

Disclaimer: This topic may contain information about third-party products. The information is for reference only. Alibaba Cloud does not make a guarantee in any form of the performance and reliability of the third-party products, and potential impacts of operations on these products.

Issue

In the Linux ECS instance, when you use the service or systemctl command to start the SSH service, the command line does not return any error information, but the service does not actually run properly. View the secure log and find an error message similar to the following.

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

Cause

The cause of this problem is usually an exception in the configuration of the PATH environment variable or the removal of files related to the SSH package.

Solution

Take note of the following items:

  • Before you perform high-risk operations such as modifying the specifications or data of an Alibaba Cloud instance, we recommend that you check the disaster recovery and fault tolerance capabilities of the instance to ensure data security.
  • Before you modify the specifications or data of an Alibaba Cloud instance, such as an Elastic Compute Service (ECS) instance or an ApsaraDB RDS instance, we recommend that you create snapshots or enable backups for the instance. For example, you can enable log backups for an ApsaraDB RDS instance.
  • If you have granted specific users the permissions on sensitive information, such as usernames and passwords, or submitted sensitive information in the Alibaba Cloud Management Console, we recommend that you modify the sensitive information at the earliest opportunity.

 

Note: The configurations and descriptions in this topic have been tested in CentOS 6.5 64-bit operating systems. The configurations of other Linux distributions may vary. For more information, see the official documentation of the corresponding distribution.

Follow these steps to check and resolve the problem.

  1. Go to the system through the Management terminal.
  1. Run the following command to check the configuration of environment variables:
    echo $PATH
    The system returns a similar value as follows. This value 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 path of the sshd program:
    find / -name sshd
    The system returns similar to the following to confirm the default path that contains the sshd program.
    /usr/sbin/sshd
  1. If the corresponding file does not exist, we recommend that you reinstall the SSH software package. You can also try to upload normal files from outside by using FTP or other methods.
  1. Run the following command to restart the SSH service:
    service sshd restart

Note: If you still have problems, see Elastic Compute Service Linux SSH failure troubleshooting guide for further troubleshooting.

Applicable scope

  • Elastic Compute Service (ECS)