Troubleshoot remote connection failures due to inactive SSH service
To connect to an instance using SSH, ensure the SSH service is running. If the service is inactive, remote connections fail. This topic explains how to check the SSH service status and start it.
Symptom
You cannot log on to a Linux ECS instance using SSH. After logging on to the instance using VNC, run the systemctl status sshd.service command to check the SSH service status (sshd.service). If the command output includes 'inactive (dead)', the SSH service is not running.
# systemctl status sshd.service
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2021-02-01 20:37:28 CST; 1s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 1034 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 1034 (code=exited, status=0/SUCCESS)
Cause
The SSH service may fail to start for several reasons, such as the service not being configured for auto-start on boot, incorrect owner or group settings for critical sshd directories, an invalid SSH service configuration file, a misconfigured PATH environment variable, or a port conflict.
Solution
-
Connect to the ECS instance using VNC.
For more information, see Connect to an instance using VNC.
-
Run the following command to check the SSH service status:
systemctl status sshd.serviceThe output 'inactive (dead)' indicates that the
sshd.serviceprocess is not running. -
Run the following commands to start the SSH service and enable auto-start on boot:
sudo systemctl start sshd.service sudo systemctl enable sshd.serviceIf an error occurs during startup, use the error message to resolve the issue. For solutions to common SSH service startup failures, see the following topics:
-
Resolve the "Read-only file system" error when modifying files on a Linux instance
-
Resolve the "Bad configuration options" error when the SSH service fails to start
-
What to do if the SSH service fails to start on a Linux ECS instance without any error messages
-
Resolve an SSH service startup failure due to a port conflict
-