In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
CentOS 7 how to change the default port of ssh, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
$vi / etc/ssh/sshd_config
Uncomment # Port 22 and add the new port Port 1111 you need to modify on the next line. (Port 22 is not deleted here to prevent the modified new port from becoming inaccessible, making it impossible to connect to the server using ssh.
Port 22Port 1111
Restart the sshd service after modifying and saving the sshd_config file:
$systemctl restart sshd
After exiting the ssh session, connect with the new port:
Configure Firewall firewalld
Enable the firewall & & check the firewall status:
$systemctl enable firewalld
$systemctl start firewalld
$systemctl status firewalld
Firewalld.service-firewalld-dynamic firewall daemon
> Loaded: loaded (/ usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
> Active: active (running) since II 2016-12-20 02:12:59 CST; 1 day 13h ago
> Main PID: 10379 (firewalld)
> CGroup: / system.slice/firewalld.service
> └─ 10379 / usr/bin/python-Es / usr/sbin/firewalld-- nofork-- nopid
$firewall-cmd-state
Running
# in case the new port does not work, expose port 22 first
$firewall-cmd-permanent-zone=public-add-port=22/tcp
$firewall-cmd-permanent-zone=public-add-port=1111/tcp
Success
Reload firewall
$firewall-cmd-reload
View exposed port rules
$firewall-cmd-permanent-list-port
443/tcp 80/tcp 22/tcp 1111/tcp
$firewall-cmd-zone=public-list-all
Public (default, active)
Interfaces: eth0 eth2
Sources:
Services: dhcpv6-client ssh
Ports: 443/tcp 80/tcp 22/tcp 1111/tcp
Masquerade: no
Forward-ports:
Icmp-blocks:
Rich rules:
After exiting ssh, try to connect to the new port
$ssh-p 1111 root@example.com
If you log in successfully, you can do the finishing touches.
Disable port 22
Delete ssh allowed port
$vi / etc/ssh/sshd_config
# Port 22
Port 1111
$systemctl restart sshd
# use ss command to check the port that ssh listens to. There is no 22 proof that the modification is successful.
$ss-tnlp | grep ssh
LISTEN 0 128 *: 1111:
Users: (("sshd", 18233)
Firewall removes port 22
$firewall-cmd-permanent-zone=public-remove-port=22/tcp
Success
$firewall-cmd-reload
$firewall-cmd-permanent-list-port
443/tcp 80/tcp 1111/tcp
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.