How to Change SSH Port in CentOS Print

  • 0

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.


Was this answer helpful?

« Back