Change SSH Port in CentOS Linux

How to change SSH port from the standard 22 to, for example 339 in CentOS Linux. Although this method helps to stop the majority of opportunistic breakin attempts (cleans your log files up nicely too) it is by no means a complete solution. You should also restrict SSH access to a single IP address, look at /etc/hosts.allow and /etc/hosts.deny - also no online server should be without a firewall.
To change the SSH Port address, using 339 as an example, do the following:
Open the sshd configuration file with your favorite editor
vi /etc/ssh/sshd_config
Find
#Port 22
Replace this with (note the removal of the hash # sign)
Port 339
Find
#Protocol 2,1
Replace this with (again note the removal of the hash # sign)
Protocol 2
Save the file: in vi, use SHIFT ZZ (in nano, press ctrl+x , press y and enter)
Restart SSHD: service sshd restart
SSH will now only allow logins on port 339 for V2 Clients
Make sure to update any Firewall that you may have installed with the new port number.
For APF Firewall this can be found in: vi /etc/apf/conf.apf
Note: Some servers may require a reboot before the changes will take place, but restarting sshd is usually sufficient.
Related Articles
- 08.04.11: Coupon Code in Order Confirmation Email - Magento (5)
- 25.02.11: Delete failed: *.php Joomla! (1)
- 21.03.11: Display mail log in CentOS Linux (0)
- 11.10.11: RSForm minimum character for phone | phone validation Joomla (0)
- 14.03.11: Turn off page titles globally in Joomla (0)









Comments RSS Feed





Cheers, one extra step, it all helps
Go to Top of the page