Troubleshoot remote connection failures due to inactive SSH service

Updated at:
Copy as MD

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

  1. Connect to the ECS instance using VNC.

    For more information, see Connect to an instance using VNC.

  2. Run the following command to check the SSH service status:

    systemctl status sshd.service

    The output 'inactive (dead)' indicates that the sshd.service process is not running.

  3. Run the following commands to start the SSH service and enable auto-start on boot:

    sudo systemctl start sshd.service
    sudo systemctl enable sshd.service

    If 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: