Linux change 22 port method summary

  

The so-called 22 port is what we often say ssh port, when you are operating Linux, if you encounter problems with the network can not connect, then there may be a problem with port 22, below Xiaobian will introduce you to the way Linux repairs 22 ports.

The first 22-port modification method:

01 If you want to change the default SSH port (22), then you just modified: /etc /ssh /sshd_config in Port 22, Here to change 22 to the port you want to set up, but do not set the same port as the existing one, in case of unknown consequences.

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

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

and then: Modify: /etc/hosts.allow, set the following settings: sshd: 192.168.0.241

This will limit the IP of only 192.168.0.241 to log in to the LINUX machine via SSH. Of course, as a server, I don't have gnome and KDE installed, and many don't install it, which increases the security factor.

The second 22 port modification method:

First modify the configuration file

vi /etc/ssh/sshd_config

Find #Port 22 section, here Yes, the ID uses 22 ports by default, modified as follows:

Port 22 Port 50000 Then save and exit

Execute /etc/init.d/sshd restart

So the SSH port will Work at the same time 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 for success. If the connection is successful, edit the sshd_config settings again and delete the Port22 inside.

The reason why the two ports are set first, and then the port is closed after the test is successful, in the process of modifying the conf, in the event of an unknown situation such as dropped calls, broken networks, misoperations, etc. It can be debugged through another port connection to prevent the connection from being sent to the computer room, which makes the problem more complicated and troublesome.

The above is the introduction of Linux repair 22 port method, this article describes two ways to modify 22 port, if you can not solve the problem after modifying port 22, then it is not a 22 port problem.

Copyright © Windows knowledge All Rights Reserved