Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does centos modify the default port number of ssh

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of how centos modifies the default port number of ssh. The content is detailed and easy to understand, easy to operate, and has a certain reference value. I believe you will gain something after reading this centos article on how to modify the default port number of ssh. Let's take a look at it.

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

You can refer to here:

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 the end of the article on "how centos modifies the default port number of ssh". Thank you for reading! I believe you all have a certain understanding of "how to modify the default port number of ssh by centos". If you want to learn more, 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report