Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of quickly modifying the remote Port of Linux Server

Shulou Source: shulou.com Published: 2022-06-02 23:38:40 11月22日 Update

About the security port of some instructions, Linux remote port default 22, a lot of cracking machines, and so on simulation guess system is to default port 22 to simulate the port 22 is very dangerous, the following 56 cloud for everyone to bring is to modify the Linux default port method!

The first:01 If you want to change Linux SSH default port (22), then you only need to modify:/etc/ssh/sshd_config Port22, where 22 to set their own port on the line, but do not set and now have the same port Oh, in case of unknown consequences. 02 If you want to restrict SSH login IP, you can do the following: first: modify/etc/hosts.deny, add sshd:ALL to it, then: modify:/etc/hosts.allow, set the following settings in it:sshd:192.168.0.241 This will restrict I to only 192.168.0.241

The first:

01 If you want to change Linux SSH default port (22), then you just need to modify Port 22 in:/etc/ssh/sshd_config, where you change 22 to the port you want to set on the line, but do not set and now have the same port Oh, in case of unknown consequences.

02 If you want to restrict SSH login IP, you can do the following:

First: modify/etc/hosts.deny to add sshd:ALL

Then: modify:/etc/hosts.allow to set it as follows:sshd: 192.168.0.241

This will limit the IP to 192.168.0.241 and log on to LINUX via SSH. Of course, as a server, I don't install gnome and KDE, and a lot of things are not installed, so increase the security factor.

Second:

Modify the configuration file first

vi /etc/ssh/sshd_config

Find the section #Port 22, here is the identifier default to use port 22, modified as follows:

Port 22

Port 50000

Then save exit

Execute/etc/init.d/sshd restart

This way SSH ports will work simultaneously with 22 and 50000.

Now edit the firewall configuration:vi /etc/sysconfig/iptables

Enable port 50000.

Execute/etc/init.d/iptables restart

Now use the ssh tool to connect to port 50000 to test success. If the connection is successful, edit the sshd_config settings again and delete Port22 inside.

The reason for setting up two ports first, and then closing one port after successful testing, is to modify the conf process, in case of unknown situations such as dropped, disconnected, misoperation, etc., can also connect through another port to debug to avoid connection must send people to the computer room, resulting in more complicated problems.

The above are several ways to modify linux ssh remote port content, more content, please use the upper right search function to obtain relevant information!

Tags: Port limit success login same security content only consequence test configuration method server service complexity danger safety factor two reason information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple vpn MariaDB OPPO Reno