Why Cannot I Use a Non-Default SSH Port to Log In to My Linux ECS?
After changing the default SSH port, I could not use the new port to log in to my ECS.
- The access to the new port is not allowed in the security group.
- The new port is not enabled on the firewall.
- The new port is not added to the SSH configuration file.
- The hosts configuration file is incorrectly configured.
Checking Security Group Rules
Check whether the security group is correctly configured.
For example, if the new SSH port number is 2020, ensure that there is a security group rule without restriction in the outbound direction and allowing access to this port in the inbound direction.
Checking Firewall Rules
Checking the SSH Configuration File
Checking the hosts Configuration File
- Add the following statement to /etc/hosts.allow to allow the IP address 192.168.1.3 to access the ECS using SSH:
- Check /etc/hosts.deny. If sshd:all:deny is contained, comment it out.
If a rule is set in both hosts.allow and hosts.deny, the rule in hosts.allow takes precedence. For example, if "sshd: 192.168.1.3" is set in hosts.allow and "sshd:all:deny" is set in hosts.deny, the ECS allows only the SSH login from IP address 192.168.1.3.