5 Simple steps to change SSH port in Centos

This article will show you, The 5 Simple steps to change SSH port in Centos.

Before I go any further, let’s see why this port has to be changed ?

Security should always be applied in layers. This provides multiple levels of protection from initial attacks, like information gathering attempts or casual threats. In addition, this layer of security should be applied within the environment so that breaking into one server after getting a pivot point in the environment should be just as difficult (if not more difficult) than the original attack that created the pivot point.

Let’s get back to the original purpose of the post.

Step 1 : Login your SSH as root user.

Step 2 : Use the below command to modify the sshd configuration file.

nano /etc/ssh/sshd_config
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

Step 3 : Navigate to “#Port 22”.

Step 4 : Remove the # to uncomment and modify the port number from 22 to your own port number as show below and save the configuration file.

Port 4325
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

Step 5 : Now, Restart the SSH server, using the below command.

/etc/init.d/sshd restart

Now, try open new SSH window with your new modified port number.

NOTE : Before closing the old session, make sure you can able to access SSH using new port number and the same was enabled in your firewall (if you are using any firewall in your server)

You may also like...

1 Response

  1. January 28, 2019

    […] your SSH port to a non-default port by reading our article on changing your servers SSH port. Want your users to only use email over SSL? Block standard POP3 and IMAP ports in your firewall to […]

Leave a Reply

Your email address will not be published.