Focus on cloud service provider activities
Notes on website operation and maintenance

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

Lao Zuo's Notes Yesterday there was“ Does the ECS choose Ubuntu or Debian image system? Select according to familiarity "It is mentioned in the article that we recommend using Debian or Ubuntu when choosing ECS systems. In recent years, Lao Zuo has been accustomed to using Ubuntu, so some netizens have been using it after seeing my suggestions. In the process of use, we have mentioned it before. It is recommended to replace the original default 22 system port with your own port after the system installation.

If we use a tool similar to the pagoda panel, we can directly replace it in the panel and modify the security group in the server. But if we directly use the Linux command to install the environment, how can we change the default port 22 of the server? In this article, lefty Record how to modify the default 22 system port in Ubuntu Ubuntu Ubuntu to provide server security policy.

First, backup the system configuration file

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

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

Second, modify the system configuration file

vi /etc/ssh/sshd_config

Here we can download it locally or use the online VIM tool for editing.

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

We can see the figure above. You can change the 22 port above to another one. For example, we can exchange 123412 for others.

After we save the file, we need to execute it.

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

We also need to release the corresponding ports. In addition, if our server has a security group, we also need to activate the settings to release this port. Of course, we can change the original 22 port.

Third, restart takes effect

/etc/init.d/sshd restart

Here we restart the SSHD to take effect. If we are other images, it is slightly different, especially the CENTOS. In this way, we can use the new port to log in to the server.

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Ubuntu Ubuntu modifies the default 22 system port to provide server security policy