In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to modify the default port number of SSH in centos. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
One: modify the / etc/ssh/sshd_config configuration file (note: this is sshd_config, not ssh_config)
1: view the default port number of ssh
Netstat-anp | grep ssh
2: modify / etc/ssh/sshd_config configuration file
Add a port number 10011 in the sshd_config file (the port 22 is reserved here to place that if the configuration fails, you can also use port 22 to log in using ssh. After the configuration is complete, you can delete port 22)
Two: firewall configuration
Here you can refer to: the basic use of linux's centos7 firewall
Three: add modified SSH port to SELinux
In many tutorials on the Internet to modify the default port number of ssh, they only talk about the above part and then restart the ssh service. I don't know how he implemented it. Anyway, I can't do it anyway. No matter how I configure it, the SSH port number has always been 22. Finally, I found out that this is because we need to add a modified SSH port to SELinux.
1: install semanage
Semanage is a management tool for SELinux and is used to add and modify SSH port numbers to SELinux.
# installation depends on yum install policycoreutils-python# to install semanageyum provides semanage
2: use semanage to add the port number we just added to SELinux (10011)
Query the current ssh service port:
Semanage port-l | grep ssh
Add the ssh port we need to add to SELinux (10011):
Semanage port-a-t ssh_port_t-p tcp 10011
Verify that the ssh port was added successfully:
Semanage port-l | grep ssh
Restart the ssh service:
Systemctl restart sshd.service
Four: test:
On the command line, enter:
Ssh root@192.168.11.201-p 10011
The following indicates that you can log in to ssh using port 10011. At this time, you can delete the configuration of port 22 in / etc/ssh/sshd_config file, and then restart the ssh service. In this case, the default port number of ssh is changed to 10011.
This is how the editor shared how to modify the default port number of SSH in centos. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.