To change the OpenSSH port number on CentOS Linux 5/6, you need to edit the sshd_config
file. Here’s how:
- Open the
sshd_config
file:
sudo nano /etc/ssh/sshd_config
- Locate the line that starts with
Port
:
Port 22
- Change the port number to the desired value (e.g., 2222):
Port 2222
- Save the changes and close the file.
- 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.