Last update at :2024-03-05,Edit by888u
The default SSH port of many Linux VPS systems is 22, but the default port 22 may be brute force cracked by others' SSH, as well as other possible security risks. This article introduces how to modify the default SSH port 22 in Linux and specify the SSH port. It is applicable to common Linux systems such as CentOS, Ubuntu, and Debian.
SSH brute force cracking
If you are using the default port 22 as the SSH port of your VPS, sometimes it may be brute force cracked by SSH. If you see the following prompt when logging in:
There were 104 failed login attempts since the last successful login.
This means that someone is trying to brute force SSH into your VPS, and you can solve this problem by modifying the default SSH port.
Modify SSH configuration file
The SSH configuration file of Linux is /etc/ssh/sshd_config. You can modify the SSH port by directly modifying this file:
vi /etc/ssh/sshd_configFind the line of code that configures the SSH port, which looks like Port 22. If there is no relevant configuration, it means the default port 22. You can add a line. For example, I set the SSH port to 29725. For security reasons, you can keep it first. There are two SSH ports, one is the original and one is new, in case you need to open the firewall and cannot log in to SSH. After ensuring that the new SSH port can be used, delete the original one. After the modification is completed Just save it directly:
Restart SSH service
After modifying the SSH configuration file, just restart the SSH service. Command:
/etc/init.d/ssh restart or: service sshd restartAfter that, you can use the new SSH port to remotely connect to the Linux VPS: Xshell tutorial: Use Xshell to connect to Linux.
Regarding the problem that CentOS7 cannot remotely connect to the new SSH port after modifying the configuration, you can refer to: "CentOS7 modifies the SSH port, and you need to set up Firewalld and SELinux to release the new port"
Recommended site search: Guangzhou website registration, agency registration, domain name registration center, mobile server rental, website registration, China agent IP, free virtual host, permanent free vps cloud host, overseas domain name, registration website,
发表评论