Why SSH works only on the standard port?

April 21, 2015 3.2k views
Security Getting Started Ubuntu

When I change the Port in /etc/ssh/sshd_config I get "Connection refused" error. When Port is 22 I can connect to server without any problems. How to fix it?

5 comments
  • After changing the ssh port are you restarting your ssh service?

    service ssh restart
    

    Unless the service is restarted the changes to your configuration will not take effect.

  • Of course, I restart ssh but it has not affected.

  • Did you open the new port your using in your firewall?

  • I don't use firewall, It is a new droplet. I follow step by step of this tutorial and earlier all work properly.

    by Justin Ellingwood
    When you start a new server, there are a few steps that you should take every time to add some basic security and set a solid foundation. In this guide, we'll walk you through the basic steps necessary to hit the ground running with Ubuntu 14.04.
  • I have the same problem. SSH works on port 22, but on other port.
    I use a LAMP droplet.
    Did you manage to find an answer?

2 Answers

For others that have this problem: Try using the IP address.
I had just transferred the domain to cloudflare and cloudflare blocks everything except http/s traffic.
To fix that, use the IP address directly or add a ssh.example.com entry to your DNS records. Or just use your local ~/.ssh/config to set your Host setting to your IP.

Don't forget firewalls:

  • UFW firewall rules on server.
  • Server Pilot Firewall
  • Local Firewalls ( antivirus, windows)
Have another answer? Share your knowledge.