To change the OpenSSH port number in Red Hat Enterprise Linux (RHEL) 5/6, you can modify the SSH daemon’s configuration file, which is located at “/etc/ssh/sshd_config”.
Here’s how you can change the OpenSSH port number:
- Open the “/etc/ssh/sshd_config” file using a text editor:
sudo vi /etc/ssh/sshd_config
- Find the line that starts with “Port” and change the port number to the desired value:
Port 22
Replace “22” with the desired port number. The default value is 22, but you can choose any unused port number between 1025 and 65535.
- Save the changes to the file and exit the text editor.
- Restart the SSH daemon to apply the changes:
sudo service ssh restart
After restarting the SSH daemon, you can use the new port number to connect to the server via SSH. For example:
ssh user@server -p newport
Replace “user” with the username for the server, “server” with the hostname or IP address of the server, and “newport” with the new port number.