In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
CentOS system how to modify the default SSH port, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this can learn, I hope you can gain something.
1. Log in to SSH to modify the configuration file. Enter the following command:
vi /etc/ssh/sshd_config
The following prompt will appear, you can see #port 22, which represents the default port 22. Press the keyboard a, vi command a is editing, you press a after entering the editing state, this time you can use the keyboard up and down keys to move the green cursor and delete the keyboard delete key in front of the #.
Tip: Why remove the #before port 22? Because #is a linux comment in the configuration file, any code after #will not be executed. SSH defaults to port 22, so configuration files appear as #by default. When you need to change to a different port or add multiport SSH access, remove the comment symbol so that the program can execute your commands.
2, as shown in the figure below, press Enter to manually add port 12366 (custom port recommended to choose 5-digit port such as: 10000-65535), keep 22 is to prevent the firewall from blocking other ports resulting in unable to connect to the VPS, such as you commented on port 22, the newly added port 12366 firewall also did not pass, then congratulations you give yourself a hole, maybe next time you will not be able to connect to the VPS through SSH. In order to prevent this embarrassing situation from happening, it is necessary to leave a way out for yourself. When the new port can be connected to SSH normally, it is not too late to delete port 22.
At this time, press the keyboard "ESC" key to exit the current state, and then enter the ": wq" command to save exit.
After the above modifications, restart the SSH service and exit the SSH port currently connected. The order reads as follows:
service sshd restart
4. Change port 22 to port 12366 in SSH software and try connecting VPS again. Click File in Xshell, open it, pop up "Session" window, change port number to 12366.
Then save, connect, at this time sadly found that can not connect to the VPS, analysis is because did not add port 12366 to the VPS firewall caused by, fortunately just left a backdoor for himself! So repeat step 4 above and change the Xshell port number back to 22 and log in to VPS.
Now add port 12366 to the firewall list. The Vi editor commands to open the firewall list are as follows:
vi /etc/sysconfig/iptables
Press a on the keyboard to enter the editing state of vi command, enter another line, use the up and down keys and delete keys to add port 12366. Do not need to understand what those commands mean, according to the port 22 as input again, just change the port from 22 to 12366 can be, note that linux is case-sensitive.
After adding a new port, press ESC on the keyboard to exit the current state, and then enter the command:":wq" to save and exit.
6. After modifying the firewall list, you must restart the firewall. The command is as follows:
service iptables restart
7. Now enter the firewall status view command as follows
service iptables status
As shown below, there is already port 12366 in the firewall rules.
8. Now repeat the steps in step 4 above to change the SSH software port to port 12366 and connect to VPS. Select "Accept and save" in the pop-up prompt, and this prompt will not appear when connecting to VPS later.
When the new port can be logged in normally, repeat the operation of step 1 above and delete the backdoor port 22 just left. Then restart SSH by following the command in step 3 above.
Today's topic is to modify the default port of centOS, but there are quite a few commands involved. Let's summarize them below.
Simple application of vi editor, a is edit,:wq is save and exit, keyboard "ESC" key is exit current state. Keyboard up and down keys and delete key delete add.
Command to edit SSH configuration file: vi /etc/ssh/sshd_config
SSH restart command: service sshd restart
Check firewall status command: service iptables status
Command to edit firewall list: vi /etc/sysconfig/iptables
Firewall restart command: service iptables restart
Note that linux is case sensitive when typing commands.
Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to 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.