VPS one hand, the first thing is to change the SSH port, using a not easy to disassemble the port number, to prevent being black.
Changing the port number is done by modifying the SSH configuration file, and after logging in SSH, enter:
Vim/etc/ssh/sshd_config
Down to find #port 22 this section
Enter VI insert mode for editing
Delete the # in front of Port 22, and then enter the new port number on the next line, such as Port 10000 (this is your own set, Max can not exceed 65535)
Edit, press ESC First, then enter: Wq save exit.
Then restart SSH with the following code:
/etc/init.d/sshd restart
Then use the 10000 port login to see if the connection is successful and the connection succeeds in removing the 22 port.
However, there is a problem, the General Linux server has its own firewall iptables rules, the port 10000 in the rule set to release.
Iptables-i input-p TCP--dport 10000-j ACCEPT
Parameter-I inserts the above rule at the top of the iptables rule, and then removes SSH's default 22 port, saves the rule, and restarts the firewall.
Next, how to delete iptables rules, sometimes some rules are too long, delete to write a large string, both waste time and easy to write wrong, then we can use –line-number to view the line number of the rule, and then deleted by line number, the code is as follows:
[Root@test ~]# iptables-nl--line-number
Chain INPUT (Policy ACCEPT)
Num Target prot opt source destination
1 DROP All--192.168.1.1 0.0.0.0/0
2 DROP All--192.168.1.2 0.0.0.0/0
3 DROP All--192.168.1.3 0.0.0.0/0
For example, to delete the second rule, enter:
[Root@test ~]# iptables-d INPUT 2