Wake up and think it is very important to modify the VPS server port in Linux and Windows Server, because SSH in Linux is Port 22 by default and Windows Remote Desktop is port 3389 by default, researchers with ulterior motives often scan these ports. If these commonly used ports are opened, they will be inspired. Therefore, whether it is a Linux server or a Windows Server, modify the default ports after getting started.
1. Modify the default port 22 of SSH on the Linux VPS server
If we modify the default port at the beginning, even if we need to guess and crack the password, we need to first find the port, at least it can increase the difficulty of VPS intrusion. In this article, jiang will share with you how to modify the default SSH port of VPS.
Step 1: vi/etc/ssh/sshd_config
Use xshell or putty to log on to VPS. The default VPS is usually port 22. Then, enter vi/etc/ssh/sshd_config to see this interface.
We only need to change the 22 number to any 5 digits (this should be appropriate ).
Step 2. Restart SSH
After modification and exit, we need to restart SSH to make the modification take effect.
The code is as follows: |
Copy code |
# Centos
/Etc/init. d/sshd restart
# Debian or ubuntu
/Etc/init. d/ssh restart
|
If we use CENTOS or debian/ubuntu, use different commands to restart SSH.
In this way, after the restart, the default port is changed, and we can use the new port to log on to SSH or SFTP, which is much more secure than the default port.
Step 3: Supplement
Generally, the above two steps are completed, but sometimes you need to set whether the firewall is enabled to ensure that the firewall is enabled.
The code is as follows: |
Copy code |
/Sbin/iptables-I INPUT-p tcp -- dport 28888 (your modified port)-j ACCEPT
/Etc/init. d/iptables save
|
In this way, we can use iptables-L-n to check whether the port is enabled.
2. Change the desktop port 3389 in the Windows system VPS server
Open the "Start" menu & rarr; "run", enter "regedit", open the registry, and enter the following path to the registry:
[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Terminal Server \ Wds \ rdpwd \ Tds \ tcp]
The PortNamber value displayed on the right is the default remote desktop port 3389, which can be changed to the desired port, such as 3333.
Open the registry key again.
[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentContro1Set \ Control \ Tenninal Server \ WinStations \ RDP \ Tcp]
Change the PortNumber value (3389 by default) to Port 3333.
After the modification, restart the computer. The port used for remote logon is 3333, and port 3389 cannot be accessed.