How To Change Port 22 SSH in Ubuntu/Debian/CentOS

The port that by default uses SSH in Linux systems is port 22 and one of the ways we can provide an improvement in security issues is to modify this port because the attackers, who know that this is the port by default and from this port will try to access the system to corrupt the entire architecture of it so today we will see how we can modify this port and thus we can make the attackers are misplaced by not being able to access from port 22.

How to modify the SSH port in Ubuntu & Debian

To modify the port in any of these two systems we must edit the ssh_config file with the editor of our liking, in this case, we will use nano, for this we enter the following:

vi /etc/ssh/ssh_config

There we look for the Port line where we can see that by default the port assigned for SSH connections is 22, there we simply modify the desired port, for example, port 155.

Note: Remember to remove # that appears in front of the port number, so that it stops being a comment and the port change is applied.

With the sudo editor, we save the changes using the key combination: Ctrl +O

And we left the editor using: Ctrl +X

Finally, we must restart the service since we edit its configuration file, for this, we use the following command:

service ssh restart

If we now try to connect to the computer using port 22 we will see the following.

How to modify the SSH port in CentOS 7

To modify the connection port by SSH on CentOS 7 devices we must edit the sshd_config file, for this, we use the editor that we like as nano or vi. We will use nano and for this, we enter the following:

sudo nano /etc/ssh/sshd_config

The port established by default is 22, we simply enter the desired port, in this case, we choose port 134.

Note: Remember to remove # that appears in front of the port number, so that it stops being a comment and the port change is applied.

We save the changes using the combination: Ctrl +O

And we left the editor using: Ctrl +X

We must restart the service so that the changes are applied using the command. In this way from now on, we will access the equipment via SSH using port 134.

service sshd restart

In this way, we can improve security at the level of access to our equipment, simply by adjusting the SSH connection port.

If we leave this port open and unprotected, we run the risk of other computers entering our computer and having access to our information.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *