How to Change SSH Port in CentOS

How to Change SSH Port in CentOS

Login to your server via PuTTY or any other SSH client.

Editing the SSH Configuration File

Once logged in, type the following command to open the SSH configuration file:

vi /etc/ssh/sshd_config

Press "i" to enter the file in edit mode.

Change the SSH Port

Scroll down to the line that says #Port 22.

Remove the # from the beginning of the line and replace 22 with your desired port number.

For example, change it to:

Port 1023

Once you've made the changes, press Esc to exit the edit mode.

Save the File and Exit

To save the file and exit, type:

:wq

Restart the SSH Service

After saving the file, restart the SSH service for the changes to take effect:

/etc/init.d/sshd restart

Login Using the New SSH Port

Now you can log in to your server via the new SSH port you configured.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Adding New IP Addresses to a CentOS/Fedora Server via SSH

Adding New IP Addresses to a CentOS/Fedora Server via SSH Follow the procedure below to add...

Disable Ping Response

Disable Ping Response What is a ping: A ping is a simple network utility used to check if a...

How To Block an IP Address

How To Block an IP Address Login to your Linux server via SSH. Blocking an IP Address To block...

How to Reset MySQL Password

How to Reset MySQL Password If you have forgotten your MySQL root password, follow these steps...

How to Add a Port to iptables in Linux

How to Add a Port to iptables in Linux Note: This document is for reference only. We do not take...