Linux exposed host SSH simple strategy protection
1. Modify the default port of the ssh service
The default port of the ssh service is 22, and ordinary malicious users often scan or try to connect to port 22. So the first step is to modify this default port.
Open /etc/ssh/sshd_config, find
Port 22
and then modify 22 to other unoccupied ports, such as 1022. It is best to be between 1-1024 to prevent port conflicts with user processes.
Then restart sshd
sudo /etc/init.d/ssh restart
2. Limit IP
First modify the /etc/hosts.allow file and add the client IP that can access the server's ssh service into it, the format is as follows
sshd:192.168.1.0/255.255.255.0
sshd:172.16.0.0/16
sshd:114.114.114.114
Then modify the /etc/hosts.deny file, add to disable other clients to connect to the ssh service
sshd: ALL
3. Check the login log
View log
more /var/log/secure
View successful login
who /var/log/wtmp