My Linux server can be pinged but cannot be connected

Updated at:

Problem description

You cannot remotely connect to an Alibaba Cloud Simple Application Server running Linux, but you can ping the server.

Causes

Possible causes:

Solutions

Make sure that your local network works properly, and then perform the following troubleshooting steps:

Check whether the server password is correct

If the remote connection fails because you entered an incorrect server password, change the server password. For more information, see Manage the password of a server.

Check whether the SSH service configuration is abnormal

  1. Connect to the server by using the rescue feature. For more information, see Connect to a Linux server by using the rescue feature.

  2. Run the following command to check whether the SSH service is listening normally.

    netstat -lntup|grep 22

    If output similar to the following is returned, the SSH service is listening normally. Dingtalk_20220426165621.jpg If the SSH service is not listening normally, see Test and verify the TCP and UDP ports of ECS instances in Linux to fix the issue.

Check whether the configuration file is abnormal

Check whether the configuration file is abnormal. For example, if certain enabled parameters prevent remote logon, comment out the parameters. For more information, see What do I do if the "Permission denied, please try again" error message appears when I log on to a Linux instance as the root user by using SSH?.

Check whether the firewall disables port 22

  1. Connect to the server by using the rescue feature. For more information, see Connect to a Linux server by using the rescue feature.

  2. Run the following command to check whether the firewall on the Linux server disables port 22 (the SSH service).

    firewall-cmd --query-port=22/tcp

    If the following output is returned, the firewall disables port 22.

    [?cdkj@he171bqz ~]# firewall-cmd --query-port=22/tcp
    no
  3. Run the following command to stop the firewall.

    systemctl stop firewalld

For more troubleshooting methods, see FAQ.