Recently, we’ve setup an Ubuntu server behind CloudFlare
that needed to listen for SSH
connections.
Unfortunately, CloudFlare
does not allow connections to the default SSH port which is 22.
So, to achieve what it was needed we either had to change the port that the SSH
service was listening to or add an additional port.
We decided to go with the option of listening to multiple ports for SSH
connections, this way users that were also behind the CloudFlare
CDN could still continue to use their SSH
clients without being forced to define the connection port manually.
The port listening setting is available in /etc/ssh/sshd_config
, using sudo
we edited the file with a text editor and searched for the following lines:
# What ports, IPs and protocols we listen for Port 22
Right after the line that contains Port 22
, we added another line for the new port (to see the list of all available open ports on CloudFlare, check this post)
And the file became as follows:
# What ports, IPs and protocols we listen for Port 22 Port 2053
Afterwards, we restarted the SSHD
service to apply the changes by executing the following command by using sudo
:
systemctl restart ssh;
This post is also available in: Αγγλικα