Introduction

SSH is secure shell of linux which run on default port 22. keeping the default port for SSH is unsecure. To Secure your SSH login we should change the port to something other than 22 .You can choose any port between 0 to 65535.Let’s see the steps

Note:- Make sure that new SSH port does not conflict with any existing running port.

How to change SSH port on Centos 7

  1. Open the sshd_config file
    vi /etc/ssh/sshd_config <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

     

  2. Locate the following line
    # Port 22 <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

     

  3. Remove # and change 22 to your desired port number.
    port 8182 <span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

    Note:- please enable port 8182 or whatever you set in your firewall

  4. Restart SSH by  running the commands below.
    systemctl restart sshd.service

     

Leave a Reply

Your email address will not be published. Required fields are marked *