All Products
Search
Document Center

:Troubleshoot SSH connection failure caused by sshd configuration errors

Last Updated:May 15, 2026

Fix sshd configuration errors that prevent SSH connections to an ECS instance by validating and correcting the sshd_config file.

Problem description

After you modify the sshd configuration file and restart the instance, you cannot connect to it with Workbench or third-party tools such as PuTTY, Xshell, and SecureCRT.

Cause

The /etc/ssh/sshd_config file contains errors that prevent sshd from starting, which blocks SSH connections to the instance.

Solution

Connect to the instance through VNC, fix errors in the sshd configuration file, and restart the sshd service.

  1. Connect to the instance through VNC.

    See Connect to an instance by using VNC.

  2. Identify the sshd binary path:

    which sshd

    The output shows sshd is located at /usr/sbin/sshd.

    image

  3. Run sshd in test mode to check for configuration errors.

    Important

    Run this command after every sshd_config change and before restarting the instance to catch errors early.

    sudo /usr/sbin/sshd -t
    • If the configuration is correct, no output is returned.

    • If errors exist, the output shows the error location. For example, the following output indicates that the value on line 144 of /etc/ssh/sshd_config is set to an unsupported value no1.

      image

  4. Fix the /etc/ssh/sshd_config file.

    1. Open the /etc/ssh/sshd_config file:

      sudo vim /etc/ssh/sshd_config
    2. Press I to enter Insert mode. Locate the error line from the previous output and fix it. For example, set UseDNS on line 144 to no.

      UseDNS no
    3. Press Esc, enter :wq, and press Enter to save and close the file.

  5. Rerun sudo /usr/sbin/sshd -t to verify the fix. If no output is returned, the configuration is correct.

    image

  6. Restart the sshd service to apply the changes.

    sudo systemctl restart sshd.service