To change the SSH port on a Linux or Unix server, you can modify the Port
directive in the /etc/ssh/sshd_config
file.
Here's an example of how to change the SSH port in the sshd_config
file:
sshd_config
file in a text editor. For example:sudo vi /etc/ssh/sshd_config
Port
directive and change the value to the desired port number. For example:Port 22
Change the value to the desired port number, such as 2222
.
Save the sshd_config
file and exit the text editor.
Restart the SSH server to apply the changes. For example:
sudo service ssh restart
After changing the SSH port, you will need to use the new port number when connecting to the server using SSH. For example:
ssh username@server_ip -p 2222