NixUser | Unix User | Linux User | NixUser

Modify SSH Port, Use one other than 22

Login to your Server or VPS as root and follow these steps to change the ssh port.

It is always a good idea to back up important server files before making any changes to them. So copy the file once you have logged into the server.

$ cp /etc/ssh/sshd_config /etc/ssh/sshd_config.back

Next, open the SSH config file with the vi editor.

$ vi /etc/ssh/sshd_config

Search for the line below in the file.

Port 22

Uncomment the line, if it is commented with a pound symbol and change the port value to the desired one. For example, use 9922. And make sure that you are not using the port number for any other services in the server.

Port 9922

The next step is to save and exit the file.

If you are running a firewall (csf/apf), please make sure that the port is open in the firewall configuration. After updating the firewall configuration with the port number, restart the firewall and then the SSH service.

$ /etc/init.d/sshd restart

Remember that you have to access SSH by specifying the new port like below.

$ ssh root@your.server.i.p -p 9922