How to change the SSH port on Linux server

To locate and edit the sshd_config file to change the SSH port, follow these steps:

1. Find the sshd_config file:
Run the command:

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

Example output:


2. Edit the file:
Open the sshd_config file using a text editor, such as nano:

nano /etc/ssh/sshd_config

3. Locate the Port option:
Find the line that reads:

Port 22


#Port 22

4. Change the port number:
To set the port to 2222 (example), modify the line to:

Port 2222

5. Save and close the file:
Press Ctrl + O to save the changes, then Ctrl + X to exit nano.

6. Restart the SSH service:
Restart the SSH service to apply the new port configuration:

service sshd restart

Please note that when choosing a new port number, it is recommended to use a value between 1024 and 65535, as ports 0-1023 are reserved for system services.

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

Related Articles

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...

Domain names are not showing in WHM

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

How to Start/Stop or Restart Apache server

Apache is the HTTP server that is freely available over the internet. It is a kind of software or...

How to install Attracta SEO Tools plugin

RequirementscPanel/WHM needs to be installed on your server. Step 1: SSH into your server and go...

How to Install CpCleaner in cPanel through SSH?

Installation Run the following shell commands as root via SSH: wget -O cpc-1.0.3.tar...