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 to modify ssh login port in Centos7

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about how to modify the ssh login port in Centos7. 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.

Recently opened a server, as long as a login at night, there are many, violently cracked login prompts, do not feel secure, only relatively secure.

# it's very scary

There were 94631 failed login attempts since the last successful login.

Their own online search, there is no very detailed solution, either the document is too old, or the document is useless, or incomplete. What a pain in the neck. Summed up by myself, I hope I can find out and use it directly when I use it later. There is no need for Google any more. The specific flow chart is as follows.

Modify SSHD configuration

Change the default port number to whatever you want, default 22, edit with vi, enter? You can find port, enter I to edit, and then esc and enter wq.

Vi / etc/ssh/sshd_config

# set the default port

Port 10086

Restart the sshd service

Check the sshd service status first, and then restart.

Systemctl status sshd.service

# Active: active (running) since Wed 2019-03-06 22:04:34 CST; 1 day 1h ago

Systemctl restart sshd.service

Add Firewall Rul

Add firewall rules, if there are no errors, just execute the firewall reload. If there are other errors, read on.

# firewall-cmd-permanent-add-port=19215/tcp

FirewallD is not running

If you prompt FirewallD is not running for this error, you need to start the firewalld service

# systemctl start firewalld

Failed to start firewalld.service: Unit is masked.

Willing to be contrary to things, the result prompted Unit is masked, enter the following command can be solved.

[root@hk1736 ~] # systemctl unmask firewalld.service

Removed symlink / etc/systemd/system/firewalld.service.

Turn on the firewall

# systemctl start firewalld

If there is nothing wrong with it, then congratulations. It doesn't matter if you are wrong. Here is the last step.

# firewall-cmd-permanent-zone=public-add-port=10086/tcp

Success

Re-import firewall rules

After adding firewall rules, you need to re-import to take effect.

# firewall-cmd-reload

Success

This is how to modify the ssh login port in the Centos7 shared by the editor. If you happen to have similar doubts, you might as well 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.

Share To

Internet Technology

Wechat

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

12
Report