Many guides and forum discuss on how to change ssh port in freepbx. But they lacks enough information to complete the process. So here we composed all steps in one page from wide internet ocean. Changing SSH port is highly recommended on a freepbx which is to internet. Hackers all over the world is constantly attempting to get into pbx using open ssh port. Lets jump into the steps

how to change ssh port freepbx,
change ssh default port freepbx

1. Login to console as root user

Login to CLI console as root user by ssh or any other console option if available. For example, The cloud service provider VULTR has the websonsole available which is a secure and easy way to access the CLI console.

2. Edit the SSHD Config file

Use any of editor to edit the sshd config file located on the directory /etc/ssh/. Here we used nano editor using the below command

nano /etc/ssh/sshd_config

Once you are on the editor,

a) scroll down and uncomment the line Port 22 by removing the # infront.
b) change port 22 to custom port. For example to port 2022

To Save, On NANO editor,

Press Control + X to exit
Enter Y on prompt and Press Enter
Press Enter again without changing file name.

3. Restart the SSH Service

SSH service will be listening to the default port 22 until we restart the SSH service after making the above change. Below goes the command for ssh service restart. Note that, if you are connected to the console via SSH , your session will be disconnected by restarting ssh service. You will have to connect back using the port updated in the config file above.

service sshd restart

4. Confirm the ssh port change

Those who are using the console by means other than SSH can use the below command to confirm the port change is in effect. Remember to finish the service restart before checking or else you should see the default port in action

systemctl status sshd.service

End note: Open the port in firewall

Most of the cloud services has got a network firewall to secure from cyber attacks. To get access to ssh using the new custom port , make sure that this particular port is open in the firewall. Or else you will get a connection error which is expected. Check with your cloud service provider on how to open custom ports .

Appreciate your valuable replied to let us know if our article on how to change ssh password in freepbx helped. If you would like to improve the information or add any missing element, please feel free to write your suggestions.

Now its your turn ! Let us know what is in your mind