To change the port number used by OpenSSH on a Red Hat Enterprise Linux (RHEL) 5 or 6 system, you will need to edit the /etc/ssh/sshd_config
configuration file. This file contains the configuration options for the OpenSSH server.
Here's a general outline of the steps you will need to follow to change the OpenSSH port number on a RHEL 5 or 6 system:
Open the /etc/ssh/sshd_config
configuration file in a text editor.
Locate the Port
directive in the file. The Port
directive specifies the port number that the OpenSSH server listens on.
Change the port number to the desired value. The port number must be a valid TCP port number between 1 and 65535.
Save the configuration file and close the text editor.
Restart the OpenSSH server to apply the changes. You can use the systemctl
command to restart the OpenSSH server.
systemctl restart ssh
ssh
command to connect to the OpenSSH server and specify the port number using the -p
option.Here's an example of how to connect to an OpenSSH server listening on port 2222:
ssh -p 2222 user@example.com
Once you have changed the OpenSSH port number and restarted the server, it should listen on the new port number and connections should be made using the new port number. Consult the OpenSSH documentation and online resources for more information on how to configure and use the OpenSSH server.