Ubuntu Ubuntu modifies the default 22 system port to provide server security policy

888u

Last update at :2024-07-12,Edit by888u

Snail Blog yesterday mentioned in the article "Which cloud server should choose Ubuntu or Debian mirror system? Choose based on familiarity" that we recommend using Debian or Ubuntu when choosing a cloud server system. In recent years, Snail is personally more accustomed to using the Ubuntu system, so some netizens are using it after seeing my suggestions. During use, in fact, we have mentioned before that it is recommended to replace the original default 22 system port with your own port after the system is installed.

If we use a tool similar to the Pagoda panel, we can directly change it in the panel and modify the security group in the server to match it. But if we directly use the Linux command installation environment, then how do we change the default port 22 of the server? In this article, Snail records how to modify the default 22 system port in Ubuntu to provide server security policy.

First, back up system configuration files

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup

Here we need to jump to the system configuration file, so I suggest you make a backup copy at the beginning so that we can recover first-aid after a failure.

Second, modify the system configuration file

vi /etc/ssh/sshd_config

Here we can download it locally or edit it using the online VIM tool.

We can see the picture above, and we can replace the port 22 above with another one. For example, if we change it to 123412, we can change it to another one ourselves.

After we save the file, we still need to execute it to take effect.

iptables -A INPUT -p tcp –dport 123412 -j ACCEPT

We still need to release the corresponding set ports. And if our server has a security group, we also need to open and set up this port. Of course, we can just replace the original 22 port.

Third, restart to take effect

/etc/init.d/sshd restart

Here we restart SSHD to take effect. If we use other mirrors, it will be slightly different, especially CENTOS. In this way, we can try to log in to the server using the new port.

Recommended site search: dual-line host rental, US server website, cloud host, domain name registration query, Google permanently free server, domain name free registration 0 yuan registration, ip proxy free version, website registration number, US vps host, domain name Registration center,

Ubuntu Ubuntu modifies the default 22 system port to provide server security policy

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码