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

What is the SSH default port number? Attached is the method to modify the customized SSH port

Today, I met a new server bought by a netizen who was unable to log in to SSH remote. Lao Zuo helped him find that the default server is not port 22, but a random five digit number. I think some of our friends have chosen more server vendors. They should know that such vendors will consider SSH default port If it is secure, it will automatically modify the port for the user. Some are default random five numbers, and some are fixed non 22 port numbers. Here we will simply sort out the SSH ports.

1、 SSH default port What's the number?

Generally, our common SSH default port is 22. Here, we also need to check whether there is a special mark of which port is on the background panel of the server.

 What is the SSH default port number? Attached is the method to modify the customized SSH port

We can see that the current ECS opened by this student is not port 22. It is 32048. If we want to log in to SSH, we use this custom port.

2. Modify the custom SSH port method

From a security perspective, we generally do not use the default port 22. We can modify the default port when installing the WEB environment, or modify port 22 during subsequent security operation and maintenance. Here, Lao Zuo modifies the default port 22 by modifying the ubuntu system.

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.

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.

/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.

If our server automatically installs an image and sets a non-22 port for us, we don't need to change it. If the default port is 22, we recommend replacing it. If a server has its own security group, we need to release the specified port and then release the corresponding port in the security group.

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( one )
Do not reprint without permission: Lao Zuo's Notes » What is the SSH default port number? Attached is the method to modify the customized SSH port

Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge