How to change the SSH port on Linux server

Run the command to locate sshd_config file:

find / -name "sshd_config" 2>/dev/null

Sample outputs:

[[email protected] ~]# find / -name "sshd_config" 2>/dev/null
[[email protected] ~]#
Edit the file and set Port option

Type the following command:

nano /etc/ssh/sshd_config

Locate the line that read as follows:
Port 22
#Port 22

To set the port to 2222, enter:
Port 2222

Save and close the file. Please note that port numbers 0-1023 are reserved for various system services. Hence, I recommend choosing port numbers between 1024 and 65535.

Restart the sshd service using the command:

service sshd restart
  • ssh, ssh port, linux, unix, cpanel, directadmin, plesk, webuzo, centos
  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

How to fix defaultwebpage.cgi on a webserver

Running the following commands solves the above problem:   /scripts/updateuserdomains...

How to fix IP Missing issue on cPanel/WHM

We are here to help you with solving the problem of Missing IP Server in list accounts. The...

Install Let's Encrypt SSL in cPanel/WHM

Let's Encrypt, a valid, open-source license that offers free SSL for your domains. The Let's...

Fix Email Issue on a server using the MSFE

To solve the problem of not sending/receiving email on a server using the MSFE / Mailscanner...

Domain names are not showing in WHM

We were unable to see any domains listed under WHM -> List Accounts. However, we can see the...