Help Center > > FAQs> Login and Connection> Remote Logins> Why Cannot I Use a Non-Default SSH Port to Log In to My Linux ECS?

Why Cannot I Use a Non-Default SSH Port to Log In to My Linux ECS?

Updated at: Mar 17, 2020 GMT+08:00

Possible Causes

After the default SSH port on a Linux ECS is changed, if the new port is not correctly configured in the SSH configuration file or firewall security policy, the new port cannot be used to log in to the ECS.


  1. Check whether the new port is correctly configured in the security group. If the changed SSH port is 12345, ensure that this port is allowed in the inbound direction when other parameters are set to Any in the outbound direction.
    Figure 1 Allowing access to port 12345
  2. Check whether port 12345 is allowed on the iptables firewall.
  3. Log in to the ECS and check the SSH configuration file.
    1. Run the following command to check whether port 12345 has been configured:

      vi /etc/ssh/sshd_config

    2. If the port has not been configured, replace #Port 22 with Port 12345.
    3. Run the following command to restart SSH:

      service sshd restart

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?

Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel