当前位置:网站首页>Change SSH port number

Change SSH port number

2022-06-24 08:46:00 Gegwu MMQ!!

The first one is :

01 If you want to change SSH Default port for (22), Then you just have to modify :/etc/ssh/sshd_config in Port 22, Here is the 22 Just change to the port you want to set , But don't set the same port as the existing one , In case of unknown consequences .

02 If you want to limit SSH Landed IP, Then you can do the following :

First : modify /etc/hosts.deny, Add to it sshd:ALL

then : modify :/etc/hosts.allow, Make the following settings :sshd:192.168.0.241

In this way, only 192.168.0.241 Of IP adopt SSH Landing LINUX It's a machine . Of course, as a server , I don't pretend gnome and KDE Of , And many don't pretend , This increases the safety factor .

The second kind :

First, modify the configuration file

vi /etc/ssh/sshd_config

find #Port 22 a section , Here is the default use of the logo 22 port , It is amended as follows :

Port 22

Port 50000

Then save to exit

perform /etc/init.d/sshd restart

such SSH The port will work simultaneously with 22 and 50000 On .

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

Enable 50000 port .

perform /etc/init.d/iptables restart

Now please use ssh Tool connection 50000 port , To test for success . If the connection is successful , Edit again sshd_config Set up , Will be inside Port22 Delete , that will do .

The reason for setting it to two ports first , Close another port after the test is successful , Is to modify the way conf In the process of , In case of a drop 、 Broken net 、 Misoperation and other unknown situations , It can also be connected and debugged through another port so as to avoid failure of connection. It is necessary to send someone to the machine room , Make the problem more complicated .

The operation steps are as follows :

Need to close early selinux;

1、 Get into /etc/vsftpd Catalog , modify vsftpd.conf The configuration file

change listen_port=21 by listen_port=801

2、 edit /etc/services file , find ftp The corresponding line

ftp 21/tcp

ftp 21/udp

Change it to

ftp 801/tcp

ftp 801/udp

3、 When the changes are complete , restart vsftpd service

/etc/init.d/vsftpd restart

4、 Add a rule to the firewall ,tcp Of 801 Port access allowed

-A INPUT -p tcp -m tcp --dport 801 -j ACCEPT

5、netstat -nltp |grep vsftp Check whether the port listening is 801

6、windows Local client access

ftp://192.168.4.100:801/

enter one user name 、 Password access ;

Or by FileZilla Client software login ;

原网站

版权声明
本文为[Gegwu MMQ!!]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240618034208.html