This document uses the CVM of the CentOS 7.5 operating system as an example to describe the troubleshooting and solutions for the problem of being unable to log in to a Linux instance via SSH.
Failure Symptoms
When using SSH to log in to a Linux instance, you receive a prompt indicating that you cannot connect or the connection fails.
Failure Location and Troubleshooting
Step one: Check the security group configuration
- Log in to the CVM console.
- On the instance management page, select the instance that needs to be troubleshooted and click More > Configure Security Group.
- In the Configure Security Group window that pops up, click the configured (checked) security group ID.
Go to the security group page bound to the instance. - On the inbound rules page of the security group rules, click One-click Release.
- In the pop-up Prompt Box, click OK.
- Use SSH to log in to the Linux instance again and check whether you can log in successfully.
- Yes, the mission completed.
- If no, perform the following step.
Step two: Check the sshd service port
Use VNC to log in to the Linux instance.
In the operating system page, perform the following command to check whether the port that the sshd service monitors is included.
netstat -tnlp | grep sshd- If the following result is returned, it means that the sshd process is monitoring on port 22. Submit a ticket for feedback.
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1015/sshd- If there is no output, the sshd service may not be started. Perform the following steps.
Step three: Check whether the sshd service is started
Perform the following command to check whether the sshd service is started.
systemctl status sshd.service
If it has been started, submit a ticket for feedback.
If it is not started, perform the following command to start the sshd service, and then use SSH to log in to the Linux instance again.
systemctl start sshd
If your instance still cannot be connected after performing the above operations, we recommend that you submit a ticket for feedback.