Troubleshoot silent SSH startup failures on Linux ECS
This article describes how to resolve an issue where the SSH service on a Linux ECS instance fails to start silently.
Symptoms
When you use the service or systemctl command to start the SSH service on a Linux ECS instance, the command completes without errors, but the service fails to start.
Check the secure log by running cat /var/log/secure. It may contain error messages similar to the following:
sshd.service: main process exited, code=exited, status=203/EXEC.
init: ssh main process (1843) terminated with status 255.
Causes
This issue typically occurs due to a misconfigured PATH environment variable or missing files from the SSH package.
Procedure
-
Connect to the ECS instance using a VNC remote connection.
For more information, see Connect to an instance by using VNC.
-
Run the following command to check the PATH environment variable:
echo $PATH-
The expected response, which is the default value for the
PATHenvironment variable, is as follows:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin -
If the output is different, the PATH environment variable has been modified. Run the following command to reset it:
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
-
-
Run the following command to find the path of the
sshdprogram:find / -name sshd-
The expected response includes the default path for the
sshdprogram, as follows:/usr/sbin/sshd -
If the file does not exist, run the following command to reinstall the SSH package:
yum install -y openssh
-
-
Run the following command to restart the SSH service:
systemctl restart sshd.service -
Run the following command to check the status of the SSH service:
systemctl status sshd.serviceOutput similar to the following indicates that the SSH service is running.
● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2023-03-17 16:27:41 CST; 5 days ago Docs: man:sshd(8) man:sshd_config(5) Main PID: 1327 (sshd) Tasks: 1 (limit: 85040) Memory: 127.9M CGroup: /system.slice/sshd.service └─1327 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc -oMACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com