How to change the ssh port on Linux or Unix server

How to change the ssh port on Linux or Unix server

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:

  1. Open the sshd_config file in a text editor. For example:
r‮:ot refe‬lautturi.com
sudo vi /etc/ssh/sshd_config
  1. Find the 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.

  1. Save the sshd_config file and exit the text editor.

  2. 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
Created Time:2017-10-28 21:38:59  Author:lautturi