How to change the 22 port

  

of the Linux system. You may not know what the 22 port is. The 22 port is the ssh port. PcAnywhere establishes TCP and the connection of this port may be to find ssh. This port can be modified, but many people under Linux do not know the method, today introduce two methods for everyone.

The first one:

01 If you want to change the default port of SSH (22), then you only need to modify: Port 22 in /etc/ssh/sshd_config, here change 22 to yourself Set the port on the line, 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.

Second:

First modify the configuration file

vi /etc/ssh/sshd_config

Find the #Port 22 section, here is the default use of the logo Port 22, modified as follows:

Port 22

Port 50000

Then save and exit

Execute /etc/init.d/sshd restart

This way the SSH port will work with both 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 two methods reflect differently. Some people like the first one, some people like the second one. In short, no matter which one can be done, the effect is good, so everyone should try it.

Copyright © Windows knowledge All Rights Reserved