CAll Us: 1-866-716-2040 Live Chat

How to change SSH port in CentOS?

Changing SSH port in Centos

The discussion below refers to any CentOS Linux servers on Apps4Rent’s Hyper-V Virtual Dedicated Server platform

To change the SSH port you need to update your sshd_config file and finally reload the configuration so that it can take effect.

NOTE: The steps provided here are on a best effort basis. If you change the port incorrectly then you would loose connectivity to your server via SSH. In such a scenario you will need to contact support. For unmanaged servers; you will be billed on an hourly basis. We will then try to reset the port and pass the details to you.
This example will assist you in changing the ssh port to nnnn<port number that you wish to use; Please replace nnnn with valid port number>
1. From your terminal session, edit /etc/ssh/sshd_config
vi /etc/ssh/sshd_config
2. Look for the following line:
#Port 22
3. Change the line so it looks like this:
Port nnnn <port number that you wish>
4. Save and close the file
5. Load the new configuration by using the service command
service sshd restart
NOTE: This command with restart sshd; and as a result you will loosed the existing connectivity to the current ssh connection. You need to open a new session of ssh and use the right ports to connect to server.
$ ssh -p nnnn <port number chosen in step 3>

Related Links:

MOSS Hosting

Windows Hyper-V Hosting

Virtual Dedicated Servers (VDS)

Hyper-V Price Plans

Hyper-V Features

Server Administration Plan

Leave a Reply