To change the ssh port of your server you first must have root access and shell access to the server. To start of we open the desired port in your firewall. For this example we will use port 12345. In our firewall configuration file we will add port 12345 to the allow list using the protocol TCP. Now we change the port for SSH:
Step 1: Open the SSH configuration file using your text editor. If we use the program pico we can edit this by typing
pico /etc/ssh/sshd_config
You should see the following text. Where we see Port 22 we change this to our desired port 12345
Port 12345
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
Use the arrow keys to move to the end of the first line and replace 22. Once this is one press CTRL + X then Press Enter. Now we need to restart the SSH daemon so we enter the command:
/sbin/service sshd restart
Now we go back into our firewall and close port 22 as SSH will not listen on that port.
Copyright PHPTutorials.co © 2009 - 2010