Beginners Guide: Change SSH Port On Ubuntu Or CentOS

If you install CSF (ConfigServer Security & Firewall) you will find in their recommend list that you need to change your SSH port for security reasons. And changing SSH port in both Ubuntu or CentOS is not hard.

To change SSH port in Linux (Ubuntu or CentOS):
1. Open your terminal with root access
2. Edit ssh_config file:

vim /etc/ssh/ssh_config

3. Change the port

Port 22 #Default SSH Port
#change to
Port 2222

4. Save and close. Then restart your SSH Server:

/etc/init.d/ssh restart

It’s easy right? Now when you connect to SSH from putty probably, you need to use port 2222 instead blank or 22. Or if you connect from a linux terminal you need to explicitly specify port 2222:

ssh [email protected] -p 2222

Give me your feedback

This site uses Akismet to reduce spam. Learn how your comment data is processed.