CentOS Linux 5/6: Change OpenSSH Port Number

To change the OpenSSH port number on CentOS Linux 5/6, you need to edit the sshd_config file. Here’s how:

  1. Open the sshd_config file:
sudo nano /etc/ssh/sshd_config
  1. Locate the line that starts with Port:
Port 22
  1. Change the port number to the desired value (e.g., 2222):
Port 2222
  1. Save the changes and close the file.
  2. Restart the SSH service to apply the changes:
sudo service ssh restart

Note: Make sure that the new port number is not blocked by any firewalls or other network security configurations.

After the changes have been applied, you will need to specify the new port number when connecting to the server via SSH. For example:

ssh user@server_ip -p 2222

Replace user with your username and server_ip with the IP address of your server.

Leave a Comment